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...?


Messages In This Thread
Howto apporach the use of parent controllers - by El Forum - 10-05-2009, 12:55 PM
Howto apporach the use of parent controllers - by El Forum - 10-05-2009, 01:00 PM



Theme © iAndrew 2016 - Forum software by © MyBB