calling controllers with hook - 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: calling controllers with hook (/showthread.php?tid=25586) |
calling controllers with hook - El Forum - 12-17-2009 [eluser]Unknown[/eluser] Hi all, Can I call a controller with a pre_controller hook. Something like this, where ControllerHook is a normal controller. Code: $hook['pre_controller'][] = array( I tried this already, it works fine. On problem is that post hook processing I get this error Code: Fatal error: Call to a member function _assign_libraries() on a non-object in F:\xampp\htdocs\trunk\system\libraries\Loader.php on line 1038 I dont know what is the issue here. Thanks in advance, Shikhar calling controllers with hook - El Forum - 12-17-2009 [eluser]Colin Williams[/eluser] The issue is that the Controller hasn't bee loaded (I mean, c'mon, the name of the hook is 'pre_controller'). You might want to move whatever code you have into the controller constructor. And your next remark is, "But I don't want to paste it into every controller." To which I say, "Put in the parent class, Controller or MY_Controller" calling controllers with hook - El Forum - 12-17-2009 [eluser]Unknown[/eluser] Thanks for the reply Collin, I know I can do it easily by extending the controller but I dont want to do that. I wanted to manage this with a hook. Yes, even though its a pre controller hook, the controller hook works fine as expected .. the problem is when the CI processes the request further I get this error. I tried with post_controller_constructor and post_controller the controller hook doesnt work. regds, Shikhar |