![]() |
Extending a 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 a controller? (/showthread.php?tid=14575) |
Extending a controller? - El Forum - 01-07-2009 [eluser]mvdg27[/eluser] Hi guys, I'm wondering if it is possible to extend a controller? I'm thinking something like this: I have a controller 'website' with a bunch of functionality. Now I would want to have something like 'website_extra', with some extra functionality and some changed functionality, but mainly the same stuff as 'website' .. it doesn't make sense to copy the everything to a new controller, does it? Is extending a controller possible within the CI framework? Thanks! Michiel Extending a controller? - El Forum - 01-07-2009 [eluser]Greg Aker[/eluser] Yes. http://ellislab.com/codeigniter/user-guide/general/creating_libraries.html [/url] Also search the forums for "MY_Controller" -greg Extending a controller? - El Forum - 01-07-2009 [eluser]sophistry[/eluser] are the EE people finally coming up for air? ;-) Extending a controller? - El Forum - 01-07-2009 [eluser]mvdg27[/eluser] Hi Greg, Thanks for your reply! I think the link you gave me applies just to libraries and I don't think that's what I'm after. I would actually want to extend my controller class as one would normally do in PHP. I've searched the forum for MY_Controller, and found some threads, but still confused about how it works exactly. Could you help me a bit on the way on this one? How could I use MY_Controller to extend 'website' with 'website_extra'? Can I use this way for different controllers as well (e.g. 'simplenews' and 'advancednews'). Thanks again! -Michiel Extending a controller? - El Forum - 01-07-2009 [eluser]sophistry[/eluser] Forget MY_Controller.php - it's for changing the behavior of the Controller Class itself. You want something like this (normal class extension): Website.php Code: <?php Website_extra.php Code: <?php Extending a controller? - El Forum - 01-08-2009 [eluser]mvdg27[/eluser] Great! That was what I was after! Thanks, Michiel |