![]() |
where should I position my extended controllers? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: where should I position my extended controllers? (/showthread.php?tid=51454) |
where should I position my extended controllers? - El Forum - 05-04-2012 [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 where should I position my extended controllers? - El Forum - 05-04-2012 [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. where should I position my extended controllers? - El Forum - 05-04-2012 [eluser]Ajaxboy[/eluser] 3 classes in 1 file extending the CI_Controller class.. not good practice where should I position my extended controllers? - El Forum - 05-11-2012 [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 where should I position my extended controllers? - El Forum - 05-11-2012 [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'); where should I position my extended controllers? - El Forum - 05-11-2012 [eluser]bill19[/eluser] Hi CroNiX, Thanks for clarifying that. I've got it working now. best regards, Bill |