I want create a Typical Controller and extends all controller from it, but CI don't find |
[eluser]Zorancho[/eluser]
First thing, create new file at application/libraries folder and name it MY_Controller.php If you want to change the prefix MY, go to application/config/config.php file, on line 106 you got this: $config['subclass_prefix'] = 'MY_'; which means you can add your own subclass prefix. You need this when you extend core classes from CI. In MY(or whatever your prefix is)_Controller.php file, create new class. Code: //This is parent of all of your controllers from application/controllers folder. Then in your application/controllers/home.php Code: class Home extends Front_Controller In your application/controllers/admin/dashboard.php Code: class Dashboard extends Admin_Controller
[eluser]Kaosland[/eluser]
Thanks It's a good exemple. But a don't understand why, i have insert a line befort _autoload then work now.!!!!! But thanks again
[eluser]Zorancho[/eluser]
Why would you want to autoload controllers? That's done in the Routing of CI according to the URL you are executing through the browser. In MVC structure such as CI, usually models could be auto loaded, but it is not necessary at all and auto loading controllers is a bad practice i think, someone please correct me if i am wrong.
[eluser]Kaosland[/eluser]
Because I have create a ControlerFront with multi lib that i had create for create&management;Background of the Front;. So i can recopy the code then what POO exits. My other controler extend from Controlerfront. SO the pobleme it'ss next when CI load controlle thenews extend controlerFont, CI don't find controlerFont. Thanks for you help.
[eluser]Zorancho[/eluser]
Then, please copy the error(s) you are getting and the code causing the errors, cause like this i really cannot help you.
[eluser]Kaosland[/eluser]
I solve error I have intoduce a blank line befor Code: //blank i don't understand why but work
[eluser]Phil Sturgeon[/eluser]
I wrote an article to explain how to do this properly. nothing new, but clearer than the random tit-bits posted on various topics. http://philsturgeon.co.uk/news/2010/02/C...ing-it-DRY
|
Welcome Guest, Not a member yet? Register Sign In |