![]() |
Subclassing 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: Subclassing Controller (/showthread.php?tid=9240) Pages:
1
2
|
Subclassing Controller - El Forum - 06-18-2008 [eluser]stoefln[/eluser] I have a class "SuperController" which extends COntroller. I wand to use this class for all my controllers. is it possible to include the supercontroller anywhere so i dont have to use require_once in each controller? Subclassing Controller - El Forum - 06-18-2008 [eluser]Seppo[/eluser] Name it MY_Controller so CI will load it when it loads Controller class Subclassing Controller - El Forum - 06-18-2008 [eluser]wiredesignz[/eluser] MY_Controller Edit: Damn.. too slow again. Good work Seppo :lol: Subclassing Controller - El Forum - 06-18-2008 [eluser]stoefln[/eluser] yeah, i love CI! Subclassing Controller - El Forum - 06-18-2008 [eluser]stoefln[/eluser] when i supply my subclasses with methods which i have defined in MY_Controller, e.g. "render"- is there a possibility to ensure that these methods can't be called from the frontend (browser)? Subclassing Controller - El Forum - 06-18-2008 [eluser]wiredesignz[/eluser] Underscore prefix the method definition, _myMethod(), underscore prefixed methods are not available to URL Subclassing Controller - El Forum - 06-18-2008 [eluser]stoefln[/eluser] [quote author="wiredesignz" date="1213810063"]Underscore prefix the method definition, _myMethod(), underscore prefixed methods are not available to URL[/quote] true. but also not callable in my subcontroller: $this->_render(...); results in Fatal error: Call to undefined method Types::_render() in D:\htdocs\codeigniter\system\application\controllers\types.php on line 46 Subclassing Controller - El Forum - 06-18-2008 [eluser]Pascal Kriete[/eluser] Probably stating the obvious - the controller has to a) extend MY_Controller and b) both the method and the call need to be changed. Other than that, I have no idea what could be going wrong. Subclassing Controller - El Forum - 06-18-2008 [eluser]stoefln[/eluser] [quote author="inparo" date="1213811508"]Probably stating the obvious - the controller has to a) extend MY_Controller and b) both the method and the call need to be changed. Other than that, I have no idea what could be going wrong.[/quote] ups. checked it again and found the problem: had 2 files and made the edits on the old, unused one. ![]() thanks for the help! Subclassing Controller - El Forum - 09-09-2008 [eluser]taewoo[/eluser] Is there a way to extend the "MY_Controller"? Meaning this MY_Controller is an abstract class that cannot be extended... then two sub-classes of MY_Controller (say Uno_Controller and Dos_Controller) that actually does "stuff": Example, in application/library/ Code: abstract class MY_Controller extends Controller then ALSO in library, there are two that extend this MY_Controller: Code: class Uno extends MY_Controller Then in the actual application/controller/XYZ.php, you extend either Dos or Uno. I can't seem to get this to work. |