Welcome Guest, Not a member yet? Register   Sign In
Howto apporach the use of parent controllers
#1

[eluser]dirkpostma[/eluser]
I want to make use of extending controllers from a controller that implements some common methods.

E.g.:

basic_controller.php
Code:
class Basic_controller extends Controller
{
  function Basic_controller()
  {
    parent::Controller();
  }
  
  function some_common_method()
  {
    // Do something common to many controllers
  }
}


main_controller.php
Code:
class Main_controller extends Basic_controller
{

  function Main_controller()
  {
    parent::Basic_controller();
  }

  function test()
  {
    $this->some_common_method();
  }
}


Unfortunately, this generates an error:
Fatal error: Class 'Basic_controller' not found in /Users/dirkpostma/Sites/citest1/controllers/main_controller.php on line 3

I could solve this by adding
Code:
include_once("basic_controller.php");

...but this is not really the CI way.

Now the (simple) question: what is the CI way of solving this problem...?
#2

[eluser]dirkpostma[/eluser]
Sorry, I searched before, but didn't find this thread yet:

http://ellislab.com/forums/viewthread/68446/

Now I did, so this one can be closed.




Theme © iAndrew 2016 - Forum software by © MyBB