Welcome Guest, Not a member yet? Register   Sign In
How to make Phill Sturgeon's modular approach using HMVC to work?
#1

[eluser]Unknown[/eluser]
What I want to do is this ( the 3rd method ):

http://philsturgeon.co.uk/blog/2009/07/C...odeIgniter

But two or more loaded controllers with the same name “admin” are not working in HMVC in CodeIgniter.
Maybe Phill was using Matchbox but in HMVC it seems not to work as in his article.

My modules structure looks like this:

Code:
modules
    admin
        controllers/
            admin.php
        models/
            admin_model.php
        views/
            admin/
                index.php
    categories/
        controllers/
            admin.php
            categories.php
        models/
            categories_model.php
        views/
            admin/
                index.php
                menu.php
            frontpage.php
    posts/
        controllers/
            admin.php
            posts.php
        models/
            posts_model.php
        views/
            admin/
                index.php
                menu.php
            frontpage.php

The admin controller looks like:
Code:
class Admin extends Backend_Controller {

    function __construct()
    {
         parent::__construct();
         $this->load->model('categories_model');
    }

    public function index()
    {
             // index stuff
    }

    public function menu()
    {
         $this->load->view('categories/admin/menu');
    }

}
And when I am calling it from another module view like this:

Code:
<?php echo Modules::run('categories/admin/menu'); ?>
it doesn't work ;(

However this works:

Code:
<?php echo Modules::run('categories/categories'); ?>
So my problem is how to load the controller with a name "admin" and not the name as the module's name and the method "menu".

Any idea how could I make it work in CodeIgniter?

I have found out that if I change my controller name from "admin" to something else e.g. "blablacontroller" it magically starts working.

I have already another module called "admin" so I think could be a problem.

How can I use multiple controllers called admin.php? I want some good repeating structure for every module and not different name for every module's admin controller.

Any idea how to solve this situation is welcome.
#2

[eluser]Unknown[/eluser]
Anybody?




Theme © iAndrew 2016 - Forum software by © MyBB