where should I position my extended controllers? |
[eluser]bill19[/eluser]
Hello , I am planning to use extended controllers for the first time. right now I have: Code: class MY_Controller extends CI_Controller { All in 1 file called MY_Controller.php in the application/libraries folder. Is this the best practice? Thanks, Bill
[eluser]CroNiX[/eluser]
Extensions to the core, like CI_Controller, go in /application/core. The file must be named MY_Controller.php, and CI will autoload it when a controller is called. CI like to have 1 class per file. If you want more extensions than 1 level, I'd suggest reading Phils article on Base Classes and check out how he autoloads them.
[eluser]Ajaxboy[/eluser]
3 classes in 1 file extending the CI_Controller class.. not good practice
[eluser]bill19[/eluser]
I am having trouble redirecting to my extended controllers, including my Home controller. I have placed them all in /application/core. However: Code: redirect('/application/core/Home'); does not work. my url string reads: Quote:http://localhost/auth/index.php/application/core/Home Thank you, Bill
[eluser]CroNiX[/eluser]
You misunderstand. Only MY_Controller (which extends CI_Controller) goes in /application/core. The rest of your controllers just go in /application/controllers like normal, but they extend MY_Controller instead of the normal CI_Controller. You can't direcly access anything in /application or /system from the URL. Those are protected. You just use the regular CI urls. Like Code: redirect('controller/method');
[eluser]bill19[/eluser]
Hi CroNiX, Thanks for clarifying that. I've got it working now. best regards, Bill |
Welcome Guest, Not a member yet? Register Sign In |