Extending the controller class: can you spot my error? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Extending the controller class: can you spot my error? (/showthread.php?tid=18766) |
Extending the controller class: can you spot my error? - El Forum - 05-17-2009 [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 { 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 { Result: Fatal error: Undefined class constant 'Controller' in C:\home\...\system\application\libraries\HANK_Controller.php on line 19 Extending the controller class: can you spot my error? - El Forum - 05-17-2009 [eluser]derekmichaeljohnson[/eluser] Your class needs to be Hank_Controller not HankController. Code: class Hank_Controller extends Controller { Code: class Videos extends Hank_Controller { Extending the controller class: can you spot my error? - El Forum - 05-17-2009 [eluser]Frank Berger[/eluser] [quote author="steward" date="1242596988"]1. Change the CI prefix: application/libraries/HANK_controller.php Code: class HankController extends Controller { Fatal error: Undefined class constant 'Controller' in C:\home\...\system\application\libraries\HANK_Controller.php on line 19[/quote] As the error states, you're trying to call a constant, and it is true, you're calling a constant. What you want to do is calling a method, so change this: Code: function HankController() to this: Code: function HankController() cheers Frank |