Mutliple Controllers - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Mutliple Controllers (/showthread.php?tid=23848) |
Mutliple Controllers - El Forum - 10-23-2009 [eluser]echoDreamz[/eluser] I am looking to load multiple controllers into CI. Basically it looks like so... Main_Site_Controller --> Base_Controller --> CI Controller Problem is right now I can only do Base_Controller -> CI Controller Reason for this is because I have the Base_Controller which extends the CI_Controller, it provides base functionality for all sites that I do, some custom items that I have. The Main_Site_Controller is really custom to each site that I do, not all, but most have different items that I need loaded without editing my base_controller. Please help me out on this one cause so far I have not found a solution to this. Mutliple Controllers - El Forum - 10-23-2009 [eluser]Michael Wales[/eluser] Seems like a whole lot of abstraction and I can't envision a scenario in which this would be beneficial. Regardless, if your config.php was setup to autoload the prefix 'Main_Site_': libraries/Base_Controller.php Code: <?php libraries/Main_Site_Controller.php Code: require('./Base_Controller.php'); controllers/users.php Code: // Finally we get to a controller that is callable by users Mutliple Controllers - El Forum - 10-23-2009 [eluser]echoDreamz[/eluser] Thanks, I was looking for a more transparent solution with the use of includes on each and every controller. Doing some editing on load_class() method in common.php resolved this for me. I have my own controllers, helpers, and libraries that are based on my companies name as the prefix, and also use libraries, helpers etc that are loosely based on the clients domain name. Also created my own loader and overwrote helper(), _ci_load_class(), and _ci_init_class() to take subclass_prefix as an array so I can pass multiple prefix names. |