CodeIgniter Forums
[Solved]redirect and post-controller/post-system 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: [Solved]redirect and post-controller/post-system hook (/showthread.php?tid=24396)



[Solved]redirect and post-controller/post-system hook - El Forum - 11-09-2009

[eluser]rogierb[/eluser]
Hi All,

This on got me baffled.
I've got a post-controller hook that checks for certain database entries.
So it checks for updates and inserts using the queries array from the DB object ($this->db->queries).

In all of my controllers I use a save method that redirects to some page after a succesfull save.
The post-controller and post-sytem hooks dont get fired because of the redirect() function.
If I remove the redirect()the hooks are fired.

So how do I fire the post-controller even with a redirect?

I need this to replace a very ugly hack done in the mysql driver so I can upgrade from 1.5.4 to something less ancient :-)

Is there some way to overload/overrride the default redirect function?(Without copying the helper to the application folder)


[Solved]redirect and post-controller/post-system hook - El Forum - 11-09-2009

[eluser]Jamie Rumbelow[/eluser]
The short answer is: you can't. The redirect() method automatically calls exit; and terminates the script, thus skipping all your hooks. One solution is to overwrite the url_helper.php and adding a custom redirect method that fixes the issue you're having.

Jamie


[Solved]redirect and post-controller/post-system hook - El Forum - 11-10-2009

[eluser]rogierb[/eluser]
yeah, that's what I thought... Well, to bad, I've written a custom redirect to execute the post-controller hook before redirecting.

Thanx Jamie!