ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Modular Extensions - Version 4.3

March 03, 2008 6:10pm

Subscribe [48]
  • #511 / Jul 10, 2008 7:37pm

    codex

    332 posts

    Why do you say IT should be looking, Really your view file should be placed in the scan path.

    I assume cms_dashboard is your controller name? located in your cms module? So where does dashboard come in? and how do you expect ME to find the file when there is no reference to dashboard anywhere?

    Try prefix segment like: $this->load->view(‘cms/dashboard/dashboard_view’);

    You do like to make life difficult for yourself. 😉

    I understand what you’re saying, but what I meant was that I expected if I explicitly set the path, ie: application/modules/cms/views/dashboard/dashboard_view.php, this would overrule the scan path and look directly into the given path. Yes, maybe I make things more difficult than they have to be, but I think apps should give me the freedom to do what I want, and not make me do what the app wants. By saying ‘stuff has to be in the scan path’ I think you lose flexibility.

  • #512 / Jul 10, 2008 7:44pm

    wiredesignz

    2882 posts

    The idea is to structure your application logically, modules ARE organizational entities, and sub-directories are sub-organizational.

    Modular Extensions is fast because you have to follow a few rules, and remember every empty path it scans takes more time.

    Think of this as name_spacing your files rather than restricting flexibility.

    I could also mention that other frameworks are even more restrictive on file location and naming.

  • #513 / Jul 10, 2008 7:51pm

    codex

    332 posts

    I could also mention that other frameworks are even more restrictive on file location and naming.

    I don’t have any experience with other frameworks so I wouldn’t know.

    Basically the way I think the localization of file should be:

    Look into the explicitly given path
    
    > if given is not a path or file is not found, look into the module
    
    > if file is not found in the module, or module doesn't exist, look into application folder
    
    > if file is not found, return error


    Does this sound logical?

  • #514 / Jul 10, 2008 8:02pm

    wiredesignz

    2882 posts

    @codex, If you want to code this up, I will consider adding it to ME.

  • #515 / Jul 10, 2008 8:18pm

    codex

    332 posts

    @codex, If you want to code this up, I will consider adding it to ME.

    That’s like asking a monkey to fix your computer.


    But hey, I’ll give it a go. Now let’s see how Zacharias did this 😉

  • #516 / Jul 10, 2008 11:40pm

    a&w

    101 posts

    Argh.  I thought I was starting to understand what you were saying about the containment of the module.  So I was thinking about something like this:

    L system (CI Core goes here)
       L libraries (CI Core libraries)
    L application1
       L libraries
          L mySharedApp1Library
    L application2
       L libraries
          L mySharedApp2Library
    L modules
       L module1
       ...
       L module4
          L controllers
              controller4 (accessor / entry point / manager) 
    
          L methods
              method4 
          L helpers
              helper4
          L models
              model4
          L views
          L libraries
             module4Class1
             module4Class2

    So, just for example, I was thinking that controller4 might need helper4.  Since we’re within a module, I took it that you’re saying to not bother using CI to get to that helper, so do NOT use CI->load->helper(‘helper4’), but instead to do require_once.  Problem with that, I hate to admit, is that I’m failing miserably trying to do include that file (how do I point to that location?).
    Ugh, maybe I should just return to matchbox. = (

  • #517 / Jul 11, 2008 5:26am

    wiredesignz

    2882 posts

    @a&w, A module controller has access to its own files. $this->load->helper(‘helper4’) is the correct way to load from controller4 in module4.

    I never said to use include or require to replace CI Loader in modules. Please read my post about loading library dependencies in the ME5 topic.

  • #518 / Jul 11, 2008 10:57am

    sophistry

    906 posts

    after a few months of looking, i am finally testing this code and i hit a snag:

    I followed the quickstart guide (fresh install of CI, welcome message working, then drop in ME 4201 files (2 application/helpers, 2 application/libraries) and i get this error when i try to get to the welcome controller:

    Fatal error: Call to a member function on a non-object in /path/to/system/application/libraries/Controller.php on line 91

    the code at line 91:

    $this->loader->_ci_autoloader();

    i am on CI 163, php4, mac osx.

    it seems like maybe the load_class() common function is being called multiple times and loses the reference to the object at some point, but i am in unfamiliar territory here in the Loader class and bootstrap process…

    any quick answers? or do i need to dig deeper and provide some more context and debugging dumps?

    thanks!

  • #519 / Jul 11, 2008 8:50pm

    wiredesignz

    2882 posts

    Hi sophistry,

    I have recently updated the wiki with Modular Extensions version 4.2.02, but I will need to check this out for you.

    Unfortunately I don’t have a PHP4 installation handy to test on, so any info you can give will help.

    EDIT:
    I think I have made a mistake while bringing ME4.2 up to spec with ME5.0,
    CI pre-loads the CI_Loader class before the Controller is instantiated.
    This is why we get that error, after trying to reload the CI_Loader a second time.

    Could you try adding this at Controller.php - line 21

    /* load the CI_Loader class */
    require_once BASEPATH.'libraries/Loader.php';

    And altering Controller.php - line 75

    /* create CI_Loader instance */
    $this->loader =& new CI_Loader();

    Let us know what results you get.
    All going well I will update the wiki with these changes.

  • #520 / Jul 11, 2008 9:51pm

    wiredesignz

    2882 posts

    Wiki is updated, Modular Extensions 4.2.03 bugfix is now available. Thanks sophistry. 😉

  • #521 / Jul 11, 2008 10:36pm

    sophistry

    906 posts

    wow! that’s all it was? i looked at the load_class() function and it seemed to have some logic to stop re-loading classes that had already been loaded. i guess there was something else going on.

    so, in case you were wondering… i made the patches and i now have a working ME system in place! running on PHP4.

    i feel like a kid on christmas eve making plans for all the new toys. 😉 hmnnn… which module shall i build out first? which of them is the best candidate for testing nesting capabilities? how can i restructure an existing app to break off some pieces into a module? ah… the possibilities. i’ll try to make some wiki changes as i go along learning this thing so that others may benefit in my wake.

    thanks for all your work on this cool tool wiredesignz, i’ll let you know how it goes.

  • #522 / Jul 11, 2008 10:57pm

    wiredesignz

    2882 posts

    You’re welcome sophistry and thanks for your input, you make the community a better place by contributing too.

    Cheers

  • #523 / Jul 12, 2008 2:01pm

    Chicken's Egg

    39 posts

    May be I’m going to ask a very silly question - in that case forgive me being a newbie - but how do you separate front- and back-end (admin-section) using modules?

    Background of this question:
    I am thinking of a website where pages and content get separated. So when calling for http://www.mydomain/page/ I would like to route this url to my default controller. This controller looks in a database which modules are used to create the content of this page, calls the controllers of those modules to receive the content, puts it together and finally displays the page as requested. I think this can be done with Modular Extensions. But, this is a description of the frond-end of the application. And before that can ever work, I must have a way to create the content-blocks and pages first. And that’s where I’m stuck. I searched this forum and the wiki and have read a lot of good things about this project. But unfortunately I didn’t find the answer.

    [edit]
    I finally found a post I can use, all-though this solution means that I have to write two separate applications. I would rather use one application.

    PS
    Would it be a good idea to create hyperlinks from the wiki-page to some of this forum threats. I’m thinking on a list like Edemilson Lima posted.
    [/edit]

  • #524 / Jul 12, 2008 5:24pm

    Chicken's Egg

    39 posts

    Is the wiki information about loading a language file correct? I get an error when I use the example: “Fatal error: Call to undefined method Modules::find() in C:\server\web\CI\edward\backend\libraries\Controller.php on line 240”. I downloaded version 4.2.03 (2008-07-04) from the Wiki-page today.

    I have got one module called welcome. It has got one controller

    <?php
    // Base Controller activeren
    include(APPPATH . 'controllers/base_controller.php');
    
    class Welcome extends Base_controller {
    
        function __construct()
        {
          // Parent class meeladen
          parent::__construct();
        }
        
        function index()
        {
          // Taal ophalen:
          $this->sLanguage = $this->config->item('language');  // Taal ophalen
          // Algemeen taalbestand inladen
          $this->load->language('home');
    
          // Main view laden
          $this->load->view('main',$this->data);
        }
    }

    For those who wonder what the base_controller file looks like:

    <?php
    class Base_controller extends Controller{
    
      var $view_dir;               // Submap waar de views in staan.
      var $data = array();         // Array om data op te slaan.
      protected $iUrl_segment;     // Segment voor menu hightlight
    
      function __construct()
      {
        // Sessie starten:
        session_start();
    
        // Error reporting:
        ini_set('display_errors', 1);
        error_reporting(E_ALL);
    
        // Controller meeladen
        parent::Controller();
    
        // Taal instellen
        if(!isset($_SESSION['taal']))
        {
          $_SESSION['taal'] = 'nl';
        }
    
        // Taal vasstleggen:
        $aTalen = array(
          'nl' => 'dutch',
          'en' => 'english',
          'fr' => 'french',
          'de' => 'german');
        $this->config->set_item('language', $aTalen[$_SESSION['taal']]);
    
    
        // Vastgestelde teksten:
        $this->data['meta_language']   = $_SESSION['taal'];
    //    $this->data['meta_charset']    = 'utf-8';
        $this->data['meta_charset']    = 'iso-8859-1';
        $this->data['meta_index']      = 'noindex';
        $this->data['meta_follow']     = 'nofollow';
        $this->data['meta_css_screen'] =  $this->config->item('media_css') . 'admin/admin_default.css';
        $this->data['meta_title']      = 'Admin Panel';
    
      }
  • #525 / Jul 12, 2008 8:50pm

    wiredesignz

    2882 posts

    Thanks Chicken’s Egg, you discovered a typo/bug in 4.2.03 language loader 😉

    Modular Extensions version 4.2.04 (bugfix) is available on the wiki now.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases