Extending controllers out of the 'core' directory |
-
iMezied Newbie

-
Posts: 1
Threads: 0
Joined: Nov 2014
Reputation:
0
(03-14-2016, 08:32 PM)kbrouill Wrote: Thanks Narf and InsiteFX for your comments.
I double checked as stated since I did express doubts on my earlier statement. Placing two or more base Controller class definitions within the single MY_Controller.php file works well.
So for those reading this conversation later on, here is a summary.
If you are trying to setup more than one BASE controller to achieve something like following class hierarchy.
CI_Controller
MyCustomFrontController extends CI_Controller
News extends MyCustomFrontController
Login extends MyCustomFrontController
About extends MyCustomFrontController
MyCustomAPIController extends CI_Controller
MembersDirectoryService extends MyCustomAPIController
ActiveUserListService extends MyCustomAPIController
All you need to do is:
- Create a MY_Controller.php file under application/core. Use MY_ or whatever prefix you configured in application/config (subclass_prefix)
- In the MY_Controller.php file declare all your base classes extending from CI_Controller or any other class within that same file.
- Create your controllers extending them from one of your many base Controllers defined in MY_Controller.php
I still wished I could have multiple base controllers, each defined in their own file baring the same name as the class. But I can live with this alternative.
Nice to find a forum that is active.
Karl
very good solution.
thank you Karl
|
Messages In This Thread |
RE: Extending controllers out of the 'core' directory - by iMezied - 06-16-2016, 01:42 PM
|