![]() |
Extending Controller? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Extending Controller? (/showthread.php?tid=32877) |
Extending Controller? - El Forum - 08-08-2010 [eluser]iConTM[/eluser] I just can't figure out how to extend the controller class properly in CI Let's say I want to have the following tree: Code: // ./system/libraries/ It works fine until level 3 (ControllerAa, ... ) Is this possible in CI? regards Extending Controller? - El Forum - 08-08-2010 [eluser]intractve[/eluser] Is there any particular reason you would like to do this? Extending Controller? - El Forum - 08-08-2010 [eluser]iConTM[/eluser] Yes there is ![]() Code: // ./system/libraries/ I would like to seperate my login and logout controllers from my other controllers (welcome, ...). but all those inherit from one main controller (MY_Controller). not the Controller in the system folder cause I would like to add some code to it ![]() Extending Controller? - El Forum - 08-08-2010 [eluser]intractve[/eluser] To me it seems like a lot of work to do something simple. I have written many web applications with codeigniter and never once had to extend the controller to bend it to my needs, I have extended a lot of the inbuilt libraries but never the Controller. But to each his own, I guess. Have fun finding out stuff in here... Maybe someone can help you with it. Cheers Extending Controller? - El Forum - 08-08-2010 [eluser]davidbehler[/eluser] Code: require_once(BASEPATH.'libraries/Controller.php'); Try this. Might work Extending Controller? - El Forum - 06-05-2011 [eluser]Chillahan[/eluser] Can anyone else provide insight on this? The MY_ extension is special, because it gets auto-loaded by the framework, right... But if one wants to have multiple "MY" controllers (like one for non-auth areas and one for, but both with the same base of default model loading, class variable loading (such as into $this->data), etc.), is there a "proper" way to do it in CI? Does the above work, and is it possibly causing more problems down the road? Extending Controller? - El Forum - 06-06-2011 [eluser]cideveloper[/eluser] This might work for you. You can make as many base controllers as you want using this method. Extending Controller? - El Forum - 06-06-2011 [eluser]Chillahan[/eluser] I should have mentioned that I did check that out already - I was left on the fence though, because it seemed from the comments that it opened some new issues with stuff being checked in the constructor not always being called. Have you used that solution successfully? I might give it another read, just seem to remember there being some other potential issues with it. I wonder why they couldn't just make it work with any number of MY_ controllers out of the box, rather than just the one. But it applies to the other core classes too I guess. Any feedback you have on Phil's base classes solution would be appreciated! |