Reputation: 2265
I want to make something like this:
Main_Controller -> {
child1_controller
child2_controller
child3_controller
}
the purpose is to execute the constructor of the Main class everytime the child classes have been executed, it looks like some kind of multi extending, for example if i want to check in the main constructor wheter is admin or not, but the problem is when i do that
child1_controller extends Main_Controller
i get an error Class 'Main_Controller' not found
Upvotes: 1
Views: 493
Reputation: 20753
Use the built in core class extending mechanism, if you name your base controller class appropriately (with the default prefix MY_
) and put it under application/core
CI should pick it up.
Once you got your MY_Controller
set up, you can make your child controllers under application/controllers/
extend that, and call for parent::__construct()
in their __construct
.
Upvotes: 4