![]() |
Hooks and Hook points - 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: Hooks and Hook points (/showthread.php?tid=2977) |
Hooks and Hook points - El Forum - 09-03-2007 [eluser]cdmn[/eluser] Hi. ive did some research with hooks and hook points and of course ive some questions. Maybe someone will be nice enough to answer them :-) My hook does nothing special, just: Code: $CI =& get_instance(); So. Hook with pre_system point: Code: Fatal error: Call to undefined function: get_instance() in ... var_dump returns NULL. Other hook points returns an object, which you can work with. So my question would be, what resourses i can use, at pre_system and pre_controller points? Of course ill need to load some libraries, should i use CI core functions like load_class? Looking for some explanation and advice :-) Hooks and Hook points - El Forum - 09-03-2007 [eluser]deviant[/eluser] You can only use get_instance once the Controller has been created as far as I know. Hooks and Hook points - El Forum - 09-03-2007 [eluser]cdmn[/eluser] Yes i understand that. But whats the purpose of pre_system and pre_controller hook points? Maybe some real application example? Hooks and Hook points - El Forum - 09-03-2007 [eluser]Nillian[/eluser] I recently used a pre-system hook to reformat 'bad' URLs. The old version of the site I'm rebuilding used query strings in the URI, whereas I'm now using CodeIgniter's friendly URLs. So, I wrote a little hook that begins before the routing system is loaded, which grabs the $_GET variable (if any) and validates the query string in the URI, then reformats it into the new friendly URLs and performs a Header("Location: [newurl]"). With this hook in place, all of the old links (on forums and peoples bookmarks etc) will still work when the new site goes live. I'm not sure if this is a good way of doing things, but it's a real world example of the pre_system hook for you ![]() Hooks and Hook points - El Forum - 09-03-2007 [eluser]cdmn[/eluser] Sweet, got the idea :-) Thanks |