Welcome Guest, Not a member yet? Register   Sign In
Modular Extensions - HMVC version 5.3

[eluser]wiredesignz[/eluser]
@loosetops, I have pushed a fix for that to Bitbucket.

[eluser]loosetops[/eluser]
That was quick.

But I still couldn't modules::run();

I have figured out work around this though, but it may need to be addressed if it's possible.

My modules tend to have a single controller almost always called 'Home'.

So in a module1/home/some_method I was doing modules::run('module2/home/another_method').
Code:
77    public static function load($module) {
78        (is_array($module)) ? list($module, $params) = each($module) : $params = NULL;    
79        
80        /* get the requested controller class name */
81        $alias = strtolower(end(explode('/', $module)));
82
83        /* return an existing controller from the registry */
84        if (isset(self::$registry[$alias])) return self::$registry[$alias];
85            
86        /* get the module path */
87        $segments = explode('/', $module);
88            
89        /* find the controller */
90        list($class) = CI::$APP->router->locate($segments);
91
92        /* controller cannot be located */
93        if (empty($class)) return;
94
95        /* set the module directory */
96        $path = APPPATH.'controllers/'.CI::$APP->router->fetch_directory();
97        
98        /* load the controller class */
99        $class = $class.CI::$APP->config->item('controller_suffix');
100        self::load_file($class, $path);
101        
102        /* create and register the new controller */
103        $controller = ucfirst($class);    
104        self::$registry[$alias] = new $controller($params);
105        return self::$registry[$alias];
106    }


It would load module2 file correct (line 100) but instantiate the wrong controller (line 104). I don't know if there is a way to remedy this.

Basically. If two controllers in different modules have the same name, you get problems cross loading them.

The work around is to rename the controller being called in modules::run() to a unique controller name, probably application wide.

Cheers.

Thanx for the help.

[eluser]WanWizard[/eluser]
Are you sure that is your issue?

You can't have two classes loaded with the same name. So if both your controllers are called Home, loading the second one will fail (you should have an error message somewhere), and line 104 instantiates the class loaded first.

Your workaround is the only possible solution. This is an issue that can only be solved by using namespaces (which isn't implemented in CI, and only available in recent versions of PHP).

[eluser]wiredesignz[/eluser]
You cannot load two classes with the same name as WanWizard states. This is a PHP (< v5.3 with namespacing) issue and has nothing to do with Modular Extensions.

My fix was only to remove the ambiguity in the modules::run method.

Modifying Modular Extensions doesn't fix your basic failure to follow PHP conventions.

[eluser]dudeami0[/eluser]
Thanks so much for this, at first I was scratching my head over a few things, then decided to just do it. In the end everything went well, and I now understand why HMVC is so awesome, keep up the great work!

[eluser]ssachan[/eluser]
Hello wiredesignz and other library users,

I am on CI 2.0 + Modular Extensions and have been able to successfully set it up :-).
There are 2 questions I would like to ask.
1. Why is the MY_Controller class in core left empty?
2. I am trying to get internationalization running and for starters I added the following lines in my routes.php
$route['default_controller'] = "welcome";
$route['^en/(.+)$'] = "$1";
$route['^en$'] = $route['default_controller'];

now if I enter a my base_url/en, it should redirect me to welcome but I get a blank screen. Could you help me please.

thanks
Shikhar

[eluser]Andy78[/eluser]
I'm working on a social networking/dating type of site that will have main page and side bar filled with widgets and so on. Similar in structure to this joomla site of mine but probably not as complicated at first.

So far im set-up and running with CI2, Modular Extensions - HMVC and ion-auth as a working module. I plan to design each widget as its own module and split the site up into an a user facing frontend and admin backend which I plan to develop overtime to have control over every aspect of the site.

My question is how to best separate the front end from the administration end Iv read this article and I think the third option is probably best for my site but when he says:
Quote:I have a single admin.php controller in the main controllers folder to act as the default admin page which will handle login, logout and the main dashboard.
I'm not sure how to implement this in Modular Extensions - HMVC. Obviously Id have a main admin controller to act as the main admin dashboard and also a main front end controller to act as the home page and load all the other modules in as widgets etc. But where should these main controllers go? each in there own modules or outside the actual module structure?

[eluser]Andy78[/eluser]
Disregard the last post, I was tired and hadn't read the article properly I see where the main controllers would go. I'm still interested in general advice with this set-up.

[eluser]Andy78[/eluser]
Ok I have run into an issue or 2

Im loading my auth login view as a partial view in my main template view like so:

Code:
&lt;!-- Begin Right Column --&gt;
         <div id="rightcolumn">
             <div id="right-inner">
            &lt;?php echo modules::run('auth/auth/login');?&gt;
             </div>          
        
         </div>
         &lt;!-- End Right Column --&gt;

This works but how do I prevent the users going directly to the view using http://localhost/auth/login for example? And also how do I get the form validation errors to display in the partial view rather than redirecting http://localhost/auth/login and displaying them?

Im probably showing my complete noobishness here but this is just a learning exercise for me. I gather its something to do with remap() but i cant get it to work.

[eluser]wiredesignz[/eluser]
Using the _remap() method in a module controller will allow you to intercept any URL based call and redirect or flag an error appropriately.




Theme © iAndrew 2016 - Forum software by © MyBB