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 - (HMVC) - Version 2.1.8

February 20, 2008 12:02am

Subscribe [6]
  • #61 / Feb 22, 2008 7:54am

    wiredesignz

    2882 posts

    @badgeek: Umm… no, it is an acceptable coding standard to leave off the closing php tag

    There should be enough info on the first page of this thread regarding installation. Just check the version number if in doubt. Current version is 2.0.2

    If you have questions just ask. We all might learn something. 😉

  • #62 / Feb 22, 2008 8:18am

    badgeek

    26 posts

    im trying to run a method on the module but theres error like this:

    A PHP Error was encountered
    Severity: Notice
    Message: Undefined variable: classes
    Filename: helpers/modules_helper.php
    Line Number: 60


    Fatal error: Cannot access empty property in W:\www\labs\app\helpers\modules_helper.php on line 101

    controller

    function index()
        {
            $this->load->helper('modules');
            modules::load('modtest');
            modules::run('modtest');
            $this->load->view('welcome_message');
        }

    module

    class Modtest extends HMVC
    {
        function Modtest()
        {
            parent::HMVC();   
        }
        
        function index()
        {
            echo "test";
        }
    }

    thanks

  • #63 / Feb 22, 2008 8:49am

    wiredesignz

    2882 posts

    Yep my bad… Will fix that. Gimme a few moments.

    However you don’t need to load a module if you intend to run it, module::run loads it and runs it.

    loading it first then running it produced the error. Thanks. 😉

  • #64 / Feb 22, 2008 8:54am

    Edemilson Lima

    241 posts

    Instead of having the models, controllers and views in a general directory and making subdirectories for files that belong together, modules have controllers, models and views in a separate directory. This makes maintenance for big or modular apps easier.

    This is not 100% correct. The modules are like controllers, but they are separated in the “modules” directory. They can load models and views only from their original directories “models” and “views”. They are not designed to group models and views in separated directories. Here is where Matchbox comes in.

  • #65 / Feb 22, 2008 9:04am

    badgeek

    26 posts

    Yep my bad… Will fix that. Gimme a few moments.

    However you don’t need to load a module if you intend to run it, module::run loads it and runs it.

    loading it first then running it produced the error. Thanks. 😉

    does it mean every time i use run method, the helper will load module? is this effective? can i load module first then call method in it?

    thanks

  • #66 / Feb 22, 2008 9:09am

    xwero

    4145 posts

    The modules are like controllers, but they are separated in the “modules” directory. They can load models and views only from their original directories “models” and “views”. They are not designed to group models and views in separated directories. Here is where Matchbox comes in.

    Thank you for clearing this up. I was under the impression the module files were grouped in the modules directory. Maybe methods could be added to function like that too?

  • #67 / Feb 22, 2008 9:20am

    wiredesignz

    2882 posts

    does it mean every time i use run method, the helper will load module? is this effective? can i load module first then call method in it?

    thanks

    No the helper checks if the module is already loaded, thats why we got the error. It was expecting to do a load and it couldn’t.

    I’m working on a fix to do either load or run, so both methods have will have the same effect, except run will do load too.

    Did that make sense? :lol:

    It’s 2:20am here so I may need sleep.  Nobody told me debugging was so intense. :lol:

  • #68 / Feb 22, 2008 9:32am

    badgeek

    26 posts

    hahah yeah you should tak a deep sleep because more bug is waiting to be smashed tomorrow,i think i found another bug:

    controller

    function index()
        {
            $this->load->helper('modules');
            modules::run('modtest',false,'testa');
            modules::run('modtest',false,'testb');
        }

    module

    class Modtest extends HMVC
    {
        function Modtest()
        {
            parent::HMVC();  
            echo "loaded";
        }
        
        function testa()
        {
            echo "run test a";
        }
        
        function testb()
        {
            echo "run test b";
        }
    }


    it will result:
    run test a

    it should be:
    run test a run test b


    this method will work fine:

    function index()
        {
            $this->load->helper('modules');
            modules::load('modtest');
            $this->modtest->testa();
            $this->modtest->testa();
        }

    thanks!

  • #69 / Feb 22, 2008 9:49am

    wiredesignz

    2882 posts

    Current version is 2.0.5
    Improved detection of already loaded modules and altered return value coming back to the run method.
    Added assign_to_models() call into CI to enable modules to be visible to models

  • #70 / Feb 22, 2008 10:16am

    Edemilson Lima

    241 posts

    Maybe methods could be added to function like that too?

    Well, the actual methods of HMVC class relies on CI Loader and you can’t specify a different directory where CI will load the models or views. I think to do this is not possible without extending the core as Matchbox do. But such thing is something that Wiredesignz want to avoid completely.

  • #71 / Feb 22, 2008 11:04am

    wiredesignz

    2882 posts

    Current version is 2.0.7
    Improvements to HMVC class - removed $this->ci from the class variables


    Could someone look at this and comment on possible memory usage issues by passing the $ci instance around in functions calls, I’m not 100% sure if its passed by reference in both PHP4 and PHP5.

    4.00am here, need sleep, Goodnight :lol:

  • #72 / Feb 22, 2008 12:13pm

    xwero

    4145 posts

    Maybe methods could be added to function like that too?

    Well, the actual methods of HMVC class relies on CI Loader and you can’t specify a different directory where CI will load the models or views. I think to do this is not possible without extending the core as Matchbox do. But such thing is something that Wiredesignz want to avoid completely.

    You are not 100% right because you only need to change the APPPATH and BASEPATH constants and you are free to put anything anywhere you want. I’ve added MY_Loader to the wiki which gives you the possibility to change those two constants. In the render method now you can do (taken from an example in the thread)

    function render()    //build the searchbox view partial
        {
            $price_opts = array(
                'All price ranges',
                'New arrivals - POA',
                'Cars under $5000',
                'Cars $5000 and over',
            );
            
            $data = array(
                'select_makes'  => form_dropdown('select-make', $this->make_opts, $this->_make),
                'select_prices' => form_dropdown('select-price', $price_opts, $this->_price)
            );
            // changed below
            $this->load->_ci_app_path = APPPATH.'modules/search/';
            $return = $this->load->view('search/box', $data, TRUE);
            $this->load->_ci_app_path = APPPATH; // for not module methods
            return $return;
        }

    It’s ugly but then you don’t have to add the matchbox library just to be able to change the file paths.

    The alternative would be instead of using the CI methods just copy the loader methods and change the file paths to be module aware. That was what i meant by adding methods.

  • #73 / Feb 22, 2008 12:47pm

    Edemilson Lima

    241 posts

    @Wiredesignz: Have nice dreams! 😊

  • #74 / Feb 22, 2008 1:16pm

    Edemilson Lima

    241 posts

    The alternative would be instead of using the CI methods just copy the loader methods and change the file paths to be module aware. That was what i meant by adding methods.

    Hmmm… I understand. It is something similar to what the first version of Modular HMVC did, replicating the Loader methods. Well, may Wiredesignz think about to add this feature, I don’t know. For my needs it is not necessary. 😊

  • #75 / Feb 22, 2008 6:51pm

    gerben

    75 posts

    wow, wiredezign!

    I don’t look on the forum for 1 day, and all of a sudden both my questions have been integrated: being able to choose a method, and integration with Matchbox (unlimited subfolders)! I’m stunned! And it all works like a charm!

    You really did a marvelous job on this.

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

ExpressionEngine News!

#eecms, #events, #releases