| Custom error (404) pages |
|
|
|
| Written by DrDigital |
| Monday, 23 June 2008 05:06 |
Custom error pagesJoomla! uses the templates/system/error.php file to handle several HTTP Status errors, including "403 Forbidden", "404 Not Found", and "500 Internal Server" Errors. You can style the error results, if desired. It is important to understand that the error.php is an independent file from Joomla!. Plugins do not run on the file. You cannot include modules or use <jdoc:include> statements. Overriding the System Error ResultsTo override the system error results, copy the templates/system/error.php file into your templates/<template-name> directory. Overriding the System StylingIf you want to change the styling, copy the templates/system/css/error.css file into your templates/<template-name>/css directory. Next, update the your templates/<template-name>/error.php file to reference the new location of the stylesheet by changing this line, accordingly: <link rel="stylesheet" href="<?php echo $this->baseurl; ?>/templates/system/css/error.css" type="text/css" />
Then, simply change the error.css, as desired, for your styling requirements. Customizing Error MessagesTo create the custom error message, dependent upon the specific error code, you'll want to add the following code somewhere in the error.php document to create the custom message. Here is an example of how display a 404 error: <?php if ($this->error->code = '404') { ?> HTTP status code When a request is made for a page on your site, the server returns an HTTP status code in response to the request. Joomla! returns a '200 - the server successfully returned the page' for error pages. This is problematic for those working with Google Webmaster Services and trying to get a sitemap resolved. If you want Joomla! to return a status code for the error, you can do so by adding logic before the DOCTYPE line, as follows: <?php
Set as favorite
Bookmark
Email This
Hits: 4498 Trackback(0)
Comments (1)
![]() written by Joshua Harrington, July 03, 2008
Thanks for this article. It's simple to do and makes quite a difference on any website.
report abuse
vote down
vote up
Votes: +0
Write comment
|
| Last Updated on Sunday, 06 July 2008 11:45 |