How to create MY_Controller for backend and frontend |
[eluser]Tống Kiện Phi[/eluser]
Now, i created MY_Controller in core folder, it apply for backend and frontand, In that case look at so confuse .. now, i want to separate if backend apply another MY_Controller and frontend apply another MY_Controller ... can do that with CI?
[eluser]xtremer360[/eluser]
What you should be doing is have the MY_Controller extend CI_Controller and then have your frontend controller and backend controller extend the MY_Controller.
[eluser]CroNiX[/eluser]
xtremer, it seems what you suggested is exactly what he is already doing. Yes, you can have a separate base controller for front end/back end, or as many as you want. Code: MY_Controller extends CI_Controller {} //common to all, main "base controller", just like you are doing Code: Front_controller extends MY_Controller {} //for front end, extends the common base Then any controller dealing with the front end would extend Front_controller, and everything dealing with the backend extends Back_controller. See this article: http://philsturgeon.co.uk/blog/2010/02/C...ing-it-DRY You'll need to create an autoload for this to work as described in the article. By default, CI only knows to load MY_Controller and not check for anything extending it.
[eluser]xtremer360[/eluser]
I thought he was but I was having problems understanding him. |
Welcome Guest, Not a member yet? Register Sign In |