How to create sub base controller class and the directory structure of it? |
[eluser]Unknown[/eluser]
Hi Guys, I have created a sub base controller class included on application/libraries folder <-- is this right? Code: abstract class MY_CMSGenBaseController extends Controller { So that on my application controller class it should be Code: class Welcome extends MY_CMSGenBaseController { Now, the script is unable to find the "MY_CMSGenBaseController" class. How can I able to attain this setup? Please provide some directory structure of it? TIA!
[eluser]Hannes Nevalainen[/eluser]
Your constructor is wrong. Code: abstract class MY_CMSGenBaseController extends Controller { Code: abstract class MY_CMSGenBaseController extends Controller { Code: class Welcome extends MY_CMSGenBaseController {
[eluser]Sumon[/eluser]
Sorry to say i follow your way but getting errors. May be i m wrong. here is my libraries\my_base_class.php Code: <?php and controllers\my_class.php Code: <?php Moreover, i have tried with autoload my_base_class in config\autoload.php.
[eluser]wiredesignz[/eluser]
Don't use MY_ unless you are extending a CI core library.
[eluser]Hannes Nevalainen[/eluser]
I'm sorry I forgot you need to call your file MY_Controller.php Your MY_Controller class should look like this: Code: abstract class MY_Controller extends Controller{
[eluser]Unknown[/eluser]
Thanks for all of your replies guys. I found the solution here: http://ellislab.com/forums/viewthread/68446/ Thanks again!
[eluser]vinod_ci[/eluser]
Hi I have to create more than one cotrollers. Because currently, In my controller the code size is beyound 4000 lines. How i put this number of functions in seperate files and again make call from main controller to this functions. I have tried one solution for this, the files are: 1. made one base controller /application/libraries/ class MY_Controller extends Controller { function MY_Controller() { parent::Controller(); } function test_vinod($xyz) { echo "hi hello"; echo $xyz; } } 2. for developer1 /application/libraries/ <?php class devloper1 extends MY_Controller { function devloper1() { parent::MY_Controller(); } function homepage() { echo "vinod"; } } same as above i want to create more classes like developer2.....3,4,5 In which developer put his own functions 3. And finally my base controller from which i can call these functions from developers <?php class Welcome extends MY_Controller { function Welcome() { parent::MY_Controller(); } function index() { $this->test_vinod('abc'); $this->load->library('devloper1'); $this->devloper1->homepage(); // likely above statement can i load more libraries (developers) // and call the functions } } My question: is it way to make compact and clear code? Thanks |
Welcome Guest, Not a member yet? Register Sign In |