Welcome Guest, Not a member yet? Register   Sign In
Can't get hooks working
#1

[eluser]Herlevsen[/eluser]
I have spent several hours now, trying to figure out why i can't get a simple hook working in codeigniter.

I have enabled hooks in config.
I tripplechecked spelling and case.

I wrote the code below in config/hooks.php:

Code:
$hook['pre_controller'] = array(
'class'    => '',
'function' => 'set_previous_page',
'filename' => 'previous_page',
'filepath' => 'hooks'
);

And then my previous_page.php file which is located in hooks folder:

Code:
function set_previous_page()
{
    echo "Hi!"; die;
}

Obviously the purpose is not to echo Hi! and then stop the script execution, but it's just to get it working. And i did try several hook points. But pre_controller i should be able to output hi and kill the script, and then have hi as the only output.

But when i load my pages, it just loads as normal.

I tried on purpose, to mess up the syntax in the hook array, and it did give me an error, and the rest of the page was not loaded. That just tells me that, at least it does recognize that i have turned hooks on.

But from here on i am just lost. Dont know what to do?

Do you have any ideas? By the way, i am using MX (modular extensions), phil sturgeons template library and Ion auth. Dont really think they should have an impact.
#2

[eluser]TheFuzzy0ne[/eluser]
The filename ends with '.php'. Wink
#3

[eluser]Herlevsen[/eluser]
Wow i feel so silly now. :red: I had just gotten too used to not typing the file extension, when dealing with routes and so on in codeigniter. But that did work! Thankyou




Theme © iAndrew 2016 - Forum software by © MyBB