Skip to main content

Custom 404 page

22 June 2010




1.  Custom design
You can customize this page and design it the way you want.

In joomla"s documentation, there"s detailed information on how it"s done.

To summarize: you need to copy the templates/system/error.php file and place it in your own template directory. Next, you also copy templates/system/css/error.css to your own temlate"s css directory. Then, you can make the changes in the error.php file. Don"t forget to pinpoint it to your own css-file.

This method needs a complete design and does not give you the opportunity to load module-positions, like your menu and such. So you have to create your own links, to your homepage, your contact details, etc.

2. Quickly create your own page within your template"s layout
This is a quick-and-dirty way of creating your own 404-article with the text you want. Create a menu link to it, preferably from a dummy menu.
This way, you can publish any module on the 404-page, including your menu.

Next, you also copy templates/system/error.php to your template"s directory. You don"t need the error"s css file, you just need to tell the error.php file to redirect to your custom 404-page. This is done with this code:

if (($this->error->code) == "404") {
header("Location: index.php?option=com_content&view=article&id=xx");
exit;
}


In Joomla"s documentation, there"s again detailed information on how it"s done.

scouting404Now when you have joomla"s SEF URL"s enabled, linking to the default URL"s could be problematic (sometimes, your template doesn"t handle out-of-the box pages and you get wrong formats). 

I solved this by using Location: http://www.yoursite.com/404


So which way is the best?


Obviously the first, as it handles all kinds of "mishaps", not just the 404. So if you want to go for it and create something special, use this one.

The second one is the fastest, however, and quickly adapts to the look-and-feel of your site. And it handles the most important "mishap". So if not much time, go for this one and be happy.





Gerelateerde links

Onderwerp

Tag

404
template

Hits

1667