Multiple MY_Controller's - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Multiple MY_Controller's (/showthread.php?tid=8930) |
Multiple MY_Controller's - El Forum - 06-05-2008 [eluser]jasonjohnson[/eluser] Is it possible to extend "Controller" in two (or more) different ways? The public side of the system I'm building needs distinctly different default controller functionality than the back-end does. Currently, I have "MY_Controller" setup to handle the back-end default controller functionality. More or less looking for "My_Controller_Public" -- not sure if that's possible. Anyone have an elegant solution to this? Thanks. Multiple MY_Controller's - El Forum - 06-05-2008 [eluser]Clooner[/eluser] You could change the prefix(detect the url in the config file and change the prefix accordingly) making it front_controller and back_controller but this will only work if you have one controller extended. Or switch to using libraries. Hope this helps, Jeroen Multiple MY_Controller's - El Forum - 06-05-2008 [eluser]xwero[/eluser] Most people who use the Controller extension file don't stick to the one file one class rule of thumb. Code: class Backend extends Controller Multiple MY_Controller's - El Forum - 06-06-2008 [eluser]marcoss[/eluser] Absolutely, here is a sampe of MY_Controller.php, Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); Multiple MY_Controller's - El Forum - 06-09-2008 [eluser]jasonjohnson[/eluser] Thanks all who replied, this gives me a much better idea as to how all this gets loaded. Much appreciate the sample code. Multiple MY_Controller's - El Forum - 06-09-2008 [eluser]wiredesignz[/eluser] Modular Extensions allows you to isolate parts of your website by using Modules. It also makes MY_Controller redundant by allowing you to autoload specific Controllers to perform initializing type tasks for others. |