Can a Controller extend another Controller? |
[eluser]Fabian Graßl[/eluser]
Hi! I would like to use the same Constructor and some private functions in two different Controllers. Therefore I would like to create a Controller that is extended by two other Controllers. Is that possible?
[eluser]esra[/eluser]
Do a search on BaseController in the forums and you should get numerous hits.
[eluser]Michael Ekoka[/eluser]
You can create a set of base controllers for your application and store them in /application/libraries/MY_Controller.php. Code: class Users_Controller extends Controller{ Code: class Members extends Users_Controller{ If you need to extend one of your application's controllers instead, make sure to include the file at the top of the script like you would normally : Code: include APPPATH.'controllers/members.php';
[eluser]Derek Allard[/eluser]
This is one of the techniques I said I liked in my review of the book "Codeigniter for Rapid PHP Application Development". If you are just starting out, you might find it helpful, but I would recommend you first start with the userguide (not implying you haven't, more just good advice )
|
Welcome Guest, Not a member yet? Register Sign In |