possible to use URI library in pre_controller 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: possible to use URI library in pre_controller hook? (/showthread.php?tid=2230) |
possible to use URI library in pre_controller hook? - El Forum - 07-23-2007 [eluser]the real rlee[/eluser] Hi, this may be a silly question but is it possible to use the URI library in a pre_controller hook? I'm getting errors telling me the object doesnt exist, but the User Docs indicate that the URI class is pre-loaded with CI and pre_controller hooks are after everything CI is loaded... Am I missing something here? Appreciate any help Code: $hook['pre_controller'] = array('class'=>'History', 'function'=>'update', 'filename'=>'History.php', 'filepath'=>'hooks', 'params'=>array()); And my hook: Code: class History { possible to use URI library in pre_controller hook? - El Forum - 07-24-2007 [eluser]the real rlee[/eluser] Wow nobody knows ? Essentially what im trying to do is recreate javascript's History object so i can redirect users around my site. Obviously sessions will be required, but im not sure how i can record each page visit automatically without literally coding it into each controller, which is why i was thinking of using a pre_controller hook to record the uri string. Anyway ideas greatly appreciated! possible to use URI library in pre_controller hook? - El Forum - 07-24-2007 [eluser]the real rlee[/eluser] Hmmm this is what im doing right now, for some reason the history session array isn't being updated i.e. it keeps create a new history item...Any ideas? Code: // Save current location possible to use URI library in pre_controller hook? - El Forum - 07-24-2007 [eluser]Shadi[/eluser] Hello, in the pre_controller hook, you won't have the CI object yet under get_instance() so a solution to use CI resources in a pre_controller hook is to do something like this: Code: class History { those four objects are the available objects in the pre_controller. Hope this helps possible to use URI library in pre_controller hook? - El Forum - 07-25-2007 [eluser]the real rlee[/eluser] Ahh thanks Shadi! Wish that was in the User Guide possible to use URI library in pre_controller hook? - El Forum - 08-26-2007 [eluser]Hamilogre[/eluser] I tried this, and it didn't seem to work. Does it work for anyone else? possible to use URI library in pre_controller hook? - El Forum - 10-25-2007 [eluser]instantations[/eluser] [quote author="the real rlee" date="1185378183"]Wish that was in the User Guide[/quote] +1 |