![]() |
[SOLVED] 404 Page Controller - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: [SOLVED] 404 Page Controller (/showthread.php?tid=16989) |
[SOLVED] 404 Page Controller - El Forum - 03-22-2009 [eluser]DougW[/eluser] I have implemented a fairly sophisticated site and want the 404 pages to be drawn in the same wrapper as the rest of the site preserving header and footer. In order to avoid duplicate code, I want to include the header and footer views within the error404.php page. Is there a way to redirect or something so that I can call a controller to then load the 404 page, thus setting all the variables I need for the header and footer before plugging in the 404 message? [SOLVED] 404 Page Controller - El Forum - 03-23-2009 [eluser]pistolPete[/eluser] This depends on your routes setup. You could add a last route: Code: $route[':any'] = 'your_error_controller'; If that's not possible for you, you'd have to extend the Router class and modify _validate_request(). [SOLVED] 404 Page Controller - El Forum - 03-23-2009 [eluser]louis w[/eluser] Here is what I am using to achieve this. Pretty straight forward. Just check to make sure the CI object is around, and if so set a variable and call it just like you would with $this-> Don't use this for error_general, it requires some additional checking to make sure there are not recursive errors. errors/error_404.php Code: <?php header("HTTP/1.1 404 Not Found"); [SOLVED] 404 Page Controller - El Forum - 04-12-2009 [eluser]vitch[/eluser] I just wrote up my solution to this problem - maybe it will help? http://www.kelvinluck.com/2009/04/custom-404-error-messages-with-codeigniter/ Cheers, Kelvin ![]() [SOLVED] 404 Page Controller - El Forum - 05-15-2009 [eluser]davidbehler[/eluser] Hey vitch, I tried to implement your solution but doesn't work for me. Seems like you need the curl library and as far as I can tell it's not available on my system. I was looking for a solution I could ship out with my blogging software and therefor I need something that runs out of the box. That's why the next version of my DBlog will be implementing louis solution that worked right away! ![]() Thx for that! [SOLVED] 404 Page Controller - El Forum - 05-15-2009 [eluser]vitch[/eluser] Hey waldmeister ![]() Yeah - I've recently started using something similar too but haven't had a chance to update my blog post yet... I posted a little more info in this other thread: http://ellislab.com/forums/viewthread/109892/P15/#576973 Hope it helps, Kelvin ![]() [SOLVED] 404 Page Controller - El Forum - 05-16-2009 [eluser]tkyy[/eluser] i usually just put a header redirect in the error file to a controller and just throw the 404 header inside of the view, display page as normal. ive modified the core of one of my projects for ci to recognize the 404 as a viewfile (404.php, if it exists) which worked very well, consider doing that. [SOLVED] 404 Page Controller - El Forum - 05-17-2009 [eluser]vitch[/eluser] The problem with just redirecting to another controller are discussed in the thread linked above. Basically it changes the URL in the user's browser which is incorrect behaviour... [SOLVED] 404 Page Controller - El Forum - 01-15-2010 [eluser]DieterStruik[/eluser] Possible solution |