Welcome Guest, Not a member yet? Register   Sign In
HMVC modules::run('module/admin/method') not working
#1

[eluser]Daniel Cronin[/eluser]
I'm using http://codeigniter.com/wiki/Modular_Extensions_-_HMVC/

When I use admin as the controller, nothing seems to work. But, if I change the controller to anything else besides admin, it works great. I made a copy of the admin file saved it as test and changed the class name to Test; and that worked.

I'm not sure if it has to do with my routing:

Code:
$route['admin/([a-zA-Z_-]+)/(:any)'] = '$1/admin/$2';
$route['admin/login'] = 'admin/login';
$route['admin/logout'] = 'admin/logout';
$route['admin/([a-zA-Z_-]+)'] = '$1/admin/index';
$route['admin'] = 'admin';
/application/modules/navigation/controllers/admin.php
modules::run('navigation/admin/testing');

Code:
<?php

class Admin extends Admin_Controller {

    function __construct()
    {
        parent::Admin_Controller();
    }
    
    function testing()
    {
        echo 'testing';
    }
}
#2

[eluser]toolwieldingape[/eluser]
change:
Code:
class Admin extends Admin_Controller {
to:
Code:
class Admin extends Controller {
and change:
Code:
parent::Admin_Controller();
to:
Code:
parent::__Construct();
#3

[eluser]Daniel Cronin[/eluser]
[quote author="toolwieldingape" date="1280851840"]change:
Code:
class Admin extends Admin_Controller {
to:
Code:
class Admin extends Controller {
and change:
Code:
parent::Admin_Controller();
to:
Code:
parent::__Construct();
[/quote]

I tried what you said and it did not work.

The Admin_Controller extends Controller. If I changed it to Admin extends Controller then I wouldn't be using any of the Admin_Controller code.

I did use parent::__contruct(); for everything except the Admin and Public controllers because it caused problems. I don't see how that would change anything because that code is functioning properly. The Admin and Public controllers use:

Code:
function Admin_Controller()
{
    parent::__construct();
}

I'm using the module structure from this page:
http://philsturgeon.co.uk/news/2009/07/C...odeIgniter

If I change the code to this it works... e.g. Change class Admin to class Blah.

Code:
<?php

class Blah extends Admin_Controller {

    function __construct()
    {
        parent::Admin_Controller();
    }
    
    function testing()
    {
        echo 'testing';
    }
}
#4

[eluser]lexusgs430[/eluser]
Well I dont know how to make it work by looking at ur question, but I can tell you why its probably not working.

From the tutorial you linked:

"This stands for Hierarchal MVC which essentially is just modular CodeIgniter. Two systems have been developed for this: HMVC and Matchbox. I personally prefer use the latter but have never tried HMVC so i'll leave that one up to you."

So the tutorial is giving specific instructions, but they are not for HMVC, so its not going to be plug and play.

And I thought in the HMVC user guide (which is remarkably small, my one complaint is I wish there was more documentation/examples, other than that I love it), I thought it mentions this type of thing as a no no.

Furthermore, I may be shortsighted as Phil is a hell of a lot smarter than me, but I dont see the point of separating the admin controller in that fashion. I mean, in the tutorial he is putting a new admin controller in each of his modules subfolders... If he wants to use his admin module on a new site he will have to rewrite all that code, where as if he were to include all of the admin base components in a admin module, he could simple download and reupload to a new site. Phil perhaps you can shed some light if Im not understanding the benefits of doing it in the way of your tutorial??
#5

[eluser]Daniel Cronin[/eluser]
[quote author="lexusgs430" date="1280884291"]Well I dont know how to make it work by looking at ur question, but I can tell you why its probably not working.

From the tutorial you linked:

"This stands for Hierarchal MVC which essentially is just modular CodeIgniter. Two systems have been developed for this: HMVC and Matchbox. I personally prefer use the latter but have never tried HMVC so i'll leave that one up to you."

So the tutorial is giving specific instructions, but they are not for HMVC, so its not going to be plug and play.

And I thought in the HMVC user guide (which is remarkably small, my one complaint is I wish there was more documentation/examples, other than that I love it), I thought it mentions this type of thing as a no no.

Furthermore, I may be shortsighted as Phil is a hell of a lot smarter than me, but I dont see the point of separating the admin controller in that fashion. I mean, in the tutorial he is putting a new admin controller in each of his modules subfolders... If he wants to use his admin module on a new site he will have to rewrite all that code, where as if he were to include all of the admin base components in a admin module, he could simple download and reupload to a new site. Phil perhaps you can shed some light if Im not understanding the benefits of doing it in the way of your tutorial??[/quote]

I chose HMVC because they had better documentation than Matchbox. Does Matchbox have a modules::run() method? So far I just created a new controller called partials.php in each module that needs to use admin modules::run().

I'm thinking I can use the same routing and route to another controller instead of admin. Using backend for example:

Code:
$route['admin/([a-zA-Z_-]+)/(:any)'] = '$1/backend/$2';
$route['admin/login'] = 'backend/login';
$route['admin/logout'] = 'backend/logout';
$route['admin/([a-zA-Z_-]+)'] = '$1/backend/index';
$route['admin'] = 'backend';

I'm not sure if that will fix it or not...

If you want to use the admin controller on a new site, you just copy the modules/module_name/ folder and it should work. If you have the admin controller in a separate folder than the modules folder; then having modules is somewhat useless... The whole point is that you can copy a module over to another application and have all the controller, models, and views all in one spot.




Theme © iAndrew 2016 - Forum software by © MyBB