自定义加载类

Hi I would like to know if it is possible to make custom load class for codeigniter. For my theme switcher system I am making.

I would like to be able to do some thing like this. I am stuck on this issue?

$this->load->controller('folder/file');

$this->load->controller('folder/folder/file');

"controller" is a custom function.

So can do this $data['name] = $this->load->controller('folder/file');

It just would make my life a lot easy if I could do it that way.

I am trying to make my own version of an min hmvc system. I know they always ask why do you need it. Always have to keep explaining it. Lots of people are after this way.

CodeIgniter manage it's class, helper, view, model, database.. loading in

system/core/Loader.php

It's why you can use

$this->load->view();
$this->load->database();
$this->load->model();
$this->load->database();

So, you can extends CI_Loader in

application/core/MY_Loader.php

add controller function and whatever you want

I found a demo in this blog post: http://www.techsirius.com/2013/01/load-controller-within-another.html

Edit:

If you want to apply to other folder like subfolder, you can add some logic to $file_name

$file_path = APPPATH.'controllers/'.$file_name.'.php';

I think it's not possible to load a controller from an other controller.

You should use Helpers instead :)

http://www.codeigniter.fr/user_guide/general/helpers.html