CI HMVC view files doesn't load from the module, instead they load from the main view

424 Views Asked by At
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class User extends MX_Controller {

    public function index()
    {
        $this->load->view('index', null);
        //$this->load->view('/user/layout', $data);
    }
}

I'am trying to load a view from the module view folder, but it loads the views from the main view folder, non those that is inside view folder, how can I force it to load from the module folder?

1

There are 1 best solutions below

0
On

Create a view file in your modules/moduleName/views folder and call it.

For example you have a module named 'user', where you've your controllers and views. Now from user module controller if you call a view named 'user_view.php' and that file doesn't exist in your modules/user/views/ folder, then codeigniter will look for that file in your application/views folder. But if that file exists in both your application/views directory and modules/user/views/ directory, then codeigniter will render the one that is in your module directory.