Welcome Guest, Not a member yet? Register   Sign In
Extending the controller class: can you spot my error?
#1

[eluser]steward[/eluser]
1. Change the CI prefix:

system/application/config.php

Code:
$config['subclass_prefix'] = 'HANK_'; // 'MY_';


2. Extend the base controller

"Note: If you need to use a constructor in your class make sure you extend the parent constructor"

application/libraries/HANK_controller.php

Code:
class HankController extends Controller {

    public $foo;

    function HankController()
    {
        parent::Controller; // THIS IS THE ERROR LINE 19
    }
}
}

3. "If you are extending the Controller core class, then be sure to extend your new class in your application controller's constructors."

application/controllers/videos.php

Code:
class Videos extends HankController {

    function Videos()
    {
        parent::HankController();
    }

    function index()
    {
        echo $this->foo;
    }

Result:


Fatal error: Undefined class constant 'Controller' in C:\home\...\system\application\libraries\HANK_Controller.php on line 19


Messages In This Thread
Extending the controller class: can you spot my error? - by El Forum - 05-17-2009, 10:49 AM
Extending the controller class: can you spot my error? - by El Forum - 05-17-2009, 10:59 AM
Extending the controller class: can you spot my error? - by El Forum - 05-17-2009, 12:53 PM



Theme © iAndrew 2016 - Forum software by © MyBB