3
votes

I have MY_Controller in core that extends CI_Controller. That works fine. But, I want to create another core controller named MY_Controller_2 for some reasons. Can I do this in codeigniter? If yes then what will be the changes in config file?

config.php

$config['subclass_prefix'] = 'MY_';

Directory Structure

core/MY_Controller
core/MY_Controller_2    <-------- I want another controller too.

MY_Controller

class MY_Controller extends CI_Controller {
function __construct()
{
    parent::__construct();
}

.....

so, basically, some of the controller files, I want to extend from MY_Controller and some from MY_Controller_2.

1

1 Answers

3
votes

By placing this at the bottom of your config.php

function __autoload($class) {
    if(strpos($class, 'CI_') !== 0) {
        @include_once( APPPATH . 'core/'. $class . EXT );
    }
}

This will load all core controllers.