Re-implementing a new controller interface |
[eluser]kakawett[/eluser]
Hi there, I'd like to know how to make a new controller, inherited from the codeigniter's core Controller one. So that I could start my controllers like this: class mycontroller extends InheritedController {...} and use extra functions and variables I'd have defined in the InheritedController class which use the Controller one as a parent.
[eluser]dudeami0[/eluser]
Seems like your looking for the MY_Controller functionality. This link will possibly help out. The basics are: Create a class named MY_Controller. Place this in the libraries folder (or core for CI2) of the application folder. Class should look like: Code: class MY_Controller extends Controller { Then simply extend all your controllers with MY_Controller and you have your unique functions
[eluser]kakawett[/eluser]
yeah i've tried that but then I have the following error : Fatal error: Class 'My_controller' not found in /home/www/m/http/application/controllers/welcome.php on line 3 In an old school PHP error style.
[eluser]dudeami0[/eluser]
Whats the name of the PHP file (Containing the MY_Controller class)?
[eluser]kakawett[/eluser]
Ok forget about it I talked too fast - created the class MY_Controller as explained on the link you gave me but the php file was nammed My_controller. Thanks for the very fast answer
[eluser]Learn CodeIgniter[/eluser]
CI 1.7.2 Put MY_Controller in application/libraries CI 2.0 Put MY_Controller in application/core
|
Welcome Guest, Not a member yet? Register Sign In |