简体   繁体   中英

Codeigniter HMVC modules in a root

I'm new on Codeigniter HMVC. I read tut how to install and work with modules and it seems everything fine.

What I'm trying is to work with modules outside application folder, but no luck.

I'm trying to browse to my url: localhost/contacts/admin

applications/config/config.php

// Modular 
$config['modules_locations'] = array(
    APPPATH.'modules/' => '../../modules/',
);

ROOT/modules/contacts/controller/contacts.php

class Contacts extends MX_Controller  {
    var $ci;
    public function __construct() {
        parent::__construct(); 
        $this->ci =& get_instance();
        $this->load->helper('url');
    }
    function admin() {
        echo 'Controller: ROOT/Modules/Contacts<br />';
        $this->load->view('admin');
    }
}

Here it seems everything OK - Controller loaded, but then I start with view, something going crazy:

I have 2 same modules. 1 in a ROOT catalog, another in application catalog. Controller is loaded from ROOT module, but view is from application catalog (application/modules/contacts/views/admin.php).

Then I delete view catalog in application/modules/contacts/view , get error:

Unable to load the requested file: admin.php

If I delete modules catalog from application folder, it load default view.

So can anyone help figure out how to work with HMVC, because until now I can't get it how it works.

what about !? :

$config['modules_locations'] = array(
   APPPATH.'modules/' =>  $['HTTP_HOST'].'/ROOT/modules',
);

by default your view need to in the,

ROOT/modules/contacts/views/

But if you want you custom Views folder, its been answered before. Please Refer this below link.

Loading view outside view folder with CodeIgniter

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM