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 5.4

January 29, 2011 1:58am

Subscribe [99]
  • #1 / Jan 29, 2011 1:58am

    wiredesignz

    2882 posts

    Modular Extensions - HMVC version 5.4 is available from Bitbucket. (see my signature below)

    CodeIgniter version 1.7 is no longer supported.

  • #2 / Jan 29, 2011 9:09am

    Twisted1919

    500 posts

    Just updated a project of mine to ci 2.0 official and HMVC 5.4, and wanted to thank you for the excellent work
    you made with hmvc 😊

  • #3 / Jan 30, 2011 6:37am

    n0xie

    1381 posts

    Thanks again wiredesignz. Your extensions has helped a lot.

  • #4 / Jan 30, 2011 3:04pm

    InsiteFX

    6819 posts

    Thank you ver much, wiredesignz…

    InsiteFX

  • #5 / Jan 30, 2011 7:17pm

    kimp

    10 posts

    Hey wiredesignz,

    Thanks, fantastic.  One quick point - it seems I can not use the get_instance() funtion in a library when the controller has inherited from MX_Controller.  Any plans to change this?  Or should I be finding a workaround for each of my libraries?

    (I raised this in an earlier post, http://ellislab.com/forums/viewthread/179478/)

    Much appreciated,

    Kim

  • #6 / Jan 30, 2011 7:28pm

    wiredesignz

    2882 posts

    With HMVC you need to pass into or set the controller instance for the library before using it.

    $this->load->library('form_validation');
    $this->form_validation->CI =& $this;
    
    /* or */
    
    $this->load->library('form_validation', array('CI' => $this));

    And then process the parameters inside the library constructor yourself.

  • #7 / Jan 30, 2011 9:34pm

    kimp

    10 posts

    Thanks.

  • #8 / Jan 31, 2011 8:21am

    Lucas Alves

    35 posts

    Thanks, wiredesignz.

    I have a doubt: Can I load a config file from a module using application/config/autoload.php $autoload?

  • #9 / Jan 31, 2011 6:17pm

    kimp

    10 posts

    Hi wiredesignz,

    Another quick point.  When I’m not using HMVC, I can access controller properties in a view using $this->variable.  As soon as MY_Controller inherits from MX_Controller, however, the property is no longer available.

    I’ve been reading up on the CI object hierarchy, including this article by David Upton, http://www.packtpub.com/article/codeigniter-and-objects, but I’m having difficulty understanding how this changes when we use HMVC…

    Any assistance appreciated…, Kim

  • #10 / Feb 01, 2011 5:18pm

    eoinmcg

    311 posts

    most useful and very much appreciated!

    thanks, wiredesignz!

  • #11 / Feb 02, 2011 12:24am

    wiredesignz

    2882 posts

    The Modular Extensions HMVC, Bitbucket repository has been updated.

    The Modules::$locations array may now be set in the application/config.php file. ie:

    /*
    |--------------------------------------------------------------------------
    | Modules locations
    |--------------------------------------------------------------------------
    */
        $config['modules_locations'] = array(
            APPPATH.'modules/' => '../modules/',
        );
  • #12 / Feb 02, 2011 7:31am

    Twisted1919

    500 posts

    With HMVC you need to pass into or set the controller instance for the library before using it.

    $this->load->library('form_validation');
    $this->form_validation->CI = $this;
    
    /* or */
    
    $this->load->library('form_validation', array('CI' => $this));

    And then process the parameters inside the library constructor.

    Hmm, i never had to do that, it just works like normal CI does.
    Any thoughts why it is working without doing your suggested trick ?

  • #13 / Mar 06, 2011 12:51am

    mannysoft

    5 posts

    Hi wiredesignz!

    First of all thanks to codeigniter and all of its friendly users.

    Im a big fan of codeigniter and HMVC and I’d been using this for a couple of years.

    I have issues regarding codeigniter 2.0 and HMVC 5.4.

    I try to use the new feature of codeigniter 2.0 which is the so called package. Using CI 2.0 I autoload the foo_bar folder that contains class called Sample with method name called tae. here is my class located in APPPATH.‘third_party/foo_bar/libraries’:

    <?php 
    class Sample
    {
        function tae()
        {
            echo 'Sample output ===!';    
        }
    }

    my autoload.php looks like:

    /*
    | -------------------------------------------------------------------
    |  Auto-load Packges
    | -------------------------------------------------------------------
    | Prototype:
    |
    |  $autoload['packages'] = array(APPPATH.'third_party', '/usr/local/shared');
    |
    */
    
    $autoload['packages'] = array(APPPATH.'third_party/foo_bar');

    when I try to load the ‘Sample’ class I get some error:

    An Error Was Encountered
    Unable to load the requested class: sample

    Here is my controller:

    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    
    class Welcome extends MX_Controller {
    
        function __construct()
        {
            parent::__construct();
            
            $this->load->library('sample');// error occurs here
            
            $this->sample->tae();
        }
    
        function index()
        {
            $this->load->view('welcome_message');
        }
    }
    
    /* End of file welcome.php */
    /* Location: ./application/controllers/welcome.php */

    but when I try to use the add_package_path:

    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    
    class Welcome extends MX_Controller {
    
        function __construct()
        {
            parent::__construct();
            
            $this->load->add_package_path(APPPATH.'third_party/foo_bar');
            $this->load->library('sample');
            
            $this->sample->tae();
        }
    
        function index()
        {
            $this->load->view('welcome_message');
        }
    }
    
    /* End of file welcome.php */
    /* Location: ./application/controllers/welcome.php */

    No errors occured. So the problem is the autoloading of package doesnt working. Some help is appreciated. Im using the latest codeigniter reactor 2.0 and HMVC version 5.4

    Thanks and more power! ^.^

  • #14 / Mar 06, 2011 1:19am

    wiredesignz

    2882 posts

    Yes, I haven’t updated Modular Extensions yet for autoloading package paths. I will do this soon.

    You could copy the CI_Loader::_ci_autoloader code for autoloading packages and add it to the MX_Loader class if you need this urgently.

  • #15 / Mar 06, 2011 1:27am

    mannysoft

    5 posts

    @wiredesignz: Thank you so much for a rapid reply!

    God Bless! ^.^

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

ExpressionEngine News!

#eecms, #events, #releases