Click on this graphic to see the code. |
Ok, so you’ve been searching around for an easy way to override the default Joomla error page to match your template.
After TWO HOURS of messing around, I finally found the page which is linked at the bottom of this post.
To summarize:
You need to edit /templates/system/error.php to regurgitate a special URL on your site for the 404. You also need to set the Status header to ‘404 Not Found’. You can see the code in the graphic above.
How this works:
On my site, /404-not-found is an SEF url linked to a menu item that shows an article called 404 Not Found.
At the top of error.php, you check the error code to see if it’s a 404. If so, then you make a call back to the server to get the text of your special 404 page.
The php function file_get_contents() will go anywhere and pull back the result. If http streams are properly configured on the server, then the file name can be a url. So, this makes the server connect to itself and get the page contents for the 404 page. Then that text is echoed back to the calling browser and the exit() function then ends processing of the request.
The calling browser gets a 404 status (which is sort of important if the calling browser is a search engine) and the text displayed is the contents of your custom 404 page served up in your active template.
You really should copy error.php to your template directory (i.e., /templates/mytemplatename/error.php) to avoid a Joomla update replacing /templates/system/error.php.
Thanks anisjoli for that!
http://www.joomlart.com/forums/showthread.php?29192-Customized-Branded-Error-(404)-Page-Joomla-Hack
Leave a Reply