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.3

August 30, 2010 3:03am

Subscribe [81]
  • #1 / Aug 30, 2010 3:03am

    wiredesignz

    2882 posts

    Modular Extensions - HMVC version 5.3.0 is available on bitbucket.

    This new version has been created to be compatible with CodeIgniter versions 1.7 and 2.0

    http://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc

    Feedback is appreciated.

    Note: Controllers must extend the MX_Controller class to use the HMVC design pattern.

  • #2 / Aug 30, 2010 7:08pm

    wiredesignz

    2882 posts

    Modular Extensions - HMVC version 5.3.1 is available on bitbucket.

  • #3 / Sep 02, 2010 7:29pm

    wiredesignz

    2882 posts

    Modular Extensions - HMVC version 5.3.2 is available on bitbucket.

  • #4 / Sep 05, 2010 8:36am

    wiredesignz

    2882 posts

    Modular Separation now runs on the same code base as Modular Extensions - HMVC and is available via my bitbucket repository.

    http://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc

    To use Modular Separation only, simply do not include the Controller.php file in MY_Controller.php or remove MY_Controller.php completely.

    Feedback is appreciated.

  • #5 / Sep 06, 2010 10:41am

    CoolGoose

    52 posts

    Just to let you know that everything you do is appreciated, I’ll check it out asap, I wished for this a long time ago.

  • #6 / Sep 06, 2010 6:45pm

    wiredesignz

    2882 posts

    @CoolGoose, Thanks.

    Modular Extensions - HMVC version 5.3.3 is available on bitbucket.

  • #7 / Sep 07, 2010 3:25am

    Ruben Müller

    10 posts

    Hey Wireesignz,

    I just tried the new version out and got it running - great work!

    But I have a Problem with “modules::run(’...’);”, I get the following error message:
    “An Error Was Encountered - Unable to locate the file: single.php”

    I checked the code and found out, that the Loader tries to load the view from the same module - thats because the “_module”-var is set in the _init-Function “$this->_module = CI::$APP->router->fetch_module();”. (MX_LOADER) But I want the view from the other module.

    Am I using the modules::run-Function wrong or did you miss that bug?

    Thanks!
    Ruben

  • #8 / Sep 07, 2010 5:40am

    wiredesignz

    2882 posts

    Try this:

    $this->load->view('module_name/view_name');
  • #9 / Sep 07, 2010 5:55am

    Ruben Müller

    10 posts

    Thanks, that did the trick!

  • #10 / Sep 08, 2010 12:17am

    I have been working with Ci for quite some time and have always been able to work my way through a problem using the excellent CI docs and the forums with success so I hesitate at posting this question. I have spent the afternoon working with the newest download of HMVC available (5.3.3) and latest ci install. I am having trouble with the form validation class, as many seem to have had in the past. Initially I was loading the library at the start of the controller function and getting:

    Severity: Notice
    Message: Undefined property: CI::$form_validation
    Filename: MX/Loader.php
    Line Number: 141

    After some research I found a number of posts making reference to extending the form validation class, which I have added to application/libraries/MY_Form_validation.php

    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
    
    class MY_Form_validation extends CI_Form_validation
    {
        function run($module = NULL, $group = '') {
            if (is_object($module)) $this->CI =& $module;
            return parent::run($group);
        }
    }
    
    /* End of file MY_Form_validation.php */
    /* Location: application/libraries/MY_Form_validation.php */

    This did not seem to correct my error so with some more research I found some references to loading the library prior to the controller using autoload.

    I removed the call to load the library in the controller and added it to my autoload.php file:

    $autoload['libraries'] = array('Form_validation');

    This did not help rid the error either.

    If I remove the MY_Controller file and operate as simply a Modular Seperation setup, the error disappears and the library functions except that it will not display the form errors when returning to the form. I would really like to retain all the functionality of this great resource as the application I am building is starting to become slightly overwhelming without the use of some type of modular seperation.

    What am I missing, or is this possibly an issue with the latest release?

    Forgive me for posting what is probably a simple question to seasoned CI veterans, but I will admit I am lost on this one.

  • #11 / Sep 08, 2010 1:17am

    wiredesignz

    2882 posts

    Apart from getting errors due to not following CI library naming conventions, you will have two options:

    Assign $this->form_validation->CI variable with an instance of the class containing the callback methods, be it either a controller or a model.

    Example:

    class Finance extends MX_Controller
    {
        public $autoload = array(
            'language'   => array('finance'),
            'config'     => array('validation'),
            'libraries'  => array('form_validation'),
            );
        
        function __construct() {
    
            parent::__construct();
            
            /* set for validation callbacks */
            $this->form_validation->CI =& $this;
            
            $rules  = $this->config->item('rules');
            $labels = $this->config->item('labels');
            
            foreach ($rules as $field => $rule) {
                $this->form_validation->set_rules($field, $labels[$field], $rule);
            }
        }
        
        function index() {

    or my preferred option:

    You can place all of your callback methods into a MY_Form_validation extension and use them as native callbacks.

  • #12 / Sep 08, 2010 7:06am

    Phil Sturgeon

    2889 posts

    I’m really excited to see this project being taken forward especially now that Modular Separation has been integrated into it.

    I’ve found a few bugs so far such as the autoloader not working with non modular content and database config not working for groups other than default but im really struggling to get MY_Controller properties read throughout the system.

    In your MX/Controller.php you have:

    <?php (defined('BASEPATH')) OR exit('No direct script access allowed');
    
    require APPPATH."third_party/MX/Controller.php";

    Other MY_ libraries in ME then create a MY_ and extend MX_ but controller does not do this. I have a MY_Controller so I am extending MX_Controller. I’d have thought MX_Controller would want to extend the main Controller but apparently it doesn’t.

    Anyhow, in MY_Controller I do lots of $this->foo = whatever then use $this->foo throughout my controllers, models, etc. Strangely all of these values work in MY_Controller when loaded and output, but when I load a model from MY_Controller and reference the global property it does not exist.

    You “da man” on this one, I’m stumped! >.<

  • #13 / Sep 08, 2010 8:30am

    wiredesignz

    2882 posts

    To use the HMVC features of my code all controllers must extend MX_Controller

    Example:

    class Any_Controller extends MX_Controller {}

    If not then you have Modular Separation features only.

  • #14 / Sep 08, 2010 8:31am

    Phil Sturgeon

    2889 posts

    Where does MY_Controller fit in, and other base classes such as Admin_Controller and Public_Controller that other controllers can extend?

  • #15 / Sep 08, 2010 8:45am

    Ruben Müller

    10 posts

    class Admin_Controller extends MX_Controller {}
    class Hello_World extends Admin_Controller {}

    ?

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

ExpressionEngine News!

#eecms, #events, #releases