![]() |
What exactly gets passed to the 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: What exactly gets passed to the hook? (/showthread.php?tid=8655) Pages:
1
2
|
What exactly gets passed to the hook? - El Forum - 05-26-2008 [eluser]oddman[/eluser] I'm trying to figure out exactly how to use the hooks so that I can check for session information upon every page request. I come from a cakephp background and it's incredibly easy in that, as they provide parent methods that allow you to execute code at any point. I'm wanting to execute a hook before the controller is called. Hints/tips on how I could do this - and what will be available to the class that I will write to handle this hook? Also, will the hook be able to set variables.etc. in the controller? Unfortunately there isn't enough documentation for this stuff =\ What exactly gets passed to the hook? - El Forum - 05-26-2008 [eluser]oddman[/eluser] *bump* Does anyone know? I'd like to be able to access controller info.etc. What exactly gets passed to the hook? - El Forum - 05-26-2008 [eluser]gtech[/eluser] well if you want to set variables in the hook i have just written a test for you. hook: Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); controller Code: <?php the temp controller printed out hi the hook was defined as Code: $hook['post_controller_constructor'] = array( I loaded it as post constructor so I could get the CI instance to set variables. In theory anything you put in the constructor should be available in the hook using the CI instance. is that what you are after? (dont forget to enable hooks in the config file) What exactly gets passed to the hook? - El Forum - 05-26-2008 [eluser]oddman[/eluser] Bingo! Ty gtech ![]() Thanks again! What exactly gets passed to the hook? - El Forum - 05-26-2008 [eluser]gtech[/eluser] no probs, glad to help. What exactly gets passed to the hook? - El Forum - 05-26-2008 [eluser]oddman[/eluser] hmmm, funnily enough it doesn't seem to be executing the code - despite having hooks enabled =\ What exactly gets passed to the hook? - El Forum - 05-26-2008 [eluser]gtech[/eluser] ok I got it working on mine.. did you place the hook in the hooks directory with the correct filename and classname? and did you place the config array in the config/hooks.php file within the php tags. did you ensure the hook had php tags around it (that was my mistake at first). try cut and pasting my example it does work honest guv ![]() What exactly gets passed to the hook? - El Forum - 05-26-2008 [eluser]oddman[/eluser] yeah, even tried different naming conventions. Isn't returning any errors =\ What exactly gets passed to the hook? - El Forum - 05-26-2008 [eluser]gtech[/eluser] did you cut and paste my example or did you use your own? my original example had a ; in the get_instance, which the forum inserted.. I edited the above script so it had a space in between the & and get, which works when executing the code. you could try upping your log_threshold see if you get any errors in the log then. What exactly gets passed to the hook? - El Forum - 05-26-2008 [eluser]oddman[/eluser] hmmm, that didn't help. Error logging set to 0. |