Welcome Guest, Not a member yet? Register   Sign In
extending MY_Controller
#1

[eluser]kmunky[/eluser]
ok, i have read on the forum how to extend Controller class but i can't find an answer to my problem.

i have



application/libraries/MY_Controller.php
Code:
class MY_Controller extends Controller(){

       function __construct(){
      
             parent::Controller();
       }
}

then i try to extend MY_Controller, (i'm trying to get two controllers, one for the frontend and oane for the admin section of my site)


application/libraries/F_Controller.php
Code:
class F_Controller extends MY_Controller{

        function _construct(){

             parent::MY_Controller();
        }
}


application/controllers/contact.php
Code:
class Contact extends F_Controller{

       function __construct(){

            parent::F_Controller();
       }
}


but all i get is Fatal error: Class 'F_Controller' not found in C:\wamp\www\...\contact.php
#2

[eluser]TaylorOtwell[/eluser]
The system is never loading F_Controller. It will only check application/core for a MY_Controller. The first thought that jumps to mind is you could setup a "pre_controller" hook that would just include your F_Controller file.
#3

[eluser]kmunky[/eluser]
so how can i do that?
#4

[eluser]TaylorOtwell[/eluser]
Look at the section on "hooks" in the User Guide. It gives details instructions much better than I could give.
#5

[eluser]n0xie[/eluser]
You can use an autoloader to do this. See this article by Phil Sturgeon about Base Classes




Theme © iAndrew 2016 - Forum software by © MyBB