Change the default Joomla Error template

What?
This is a quick article on what I change the error page for Joomla websites to. I like a clean error page, for a demo visit http://www.joellipman.com/my_error_page.
  • Applies to Joomla 1.6.x, 1.7.x, 2.5.x

How?
  1. Backup the file \templates\system\error.php
  2. Create a replacement file called error.php including the below code
  3. Change the message "The Page you are looking for..." to what you want.
  4. Change the link "www.joellipman.com" to the "www.yoursitename.com".
  5. [Optional] If you want the image that creates the shadow you can download it here. I put it in the folder \templates\system\images.
copyraw
<?php
/**
 * @package     Joomla 2.5.x - Clean Error Page
 * @copyright   Copyright (C) 2013 Joel Lipman .Com. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;
if (!isset($this->error)) {
        $this->error = JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
        $this->debug = false;
}
//get language and direction
$doc = JFactory::getDocument();
$this->language = $doc->language;
$this->direction = $doc->direction;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
<head>
        <title><?php echo $this->error->getCode(); ?> - <?php echo $this->title; ?></title>
        <style>
                .error > span {position:relative;}
                .error > span:before {content:"";position:absolute;top:70%;left:-30px;right:-30px;height:80px;background:url(/templates/system/images/error_shadow.png) no-repeat;background-size:100% 100%;}
                .error {text-shadow:0 -1px 0 rgba(0,0,0,0.9), 0 1px 0 rgba(255,255,255,0.7);font-size:200px;font-weight:700;position:relative;top:50px;}
                h1,h2,h3,h4,h5,h6 {color:#505050;font-weight:400;}
                h1 {line-height:36px;font-size:2em;font-weight:700;}
                .center {text-align:center;}
                body {font:normal 14px/20px Arial, Helvetica, sans-serif;color:#777;}
                .title {margin:20px 0 0;}
                h2 {font-size:24px;line-height:24px;}
                .message {width:400px;margin:20px auto 0;text-align:justify;}
        </style>
</head>
<body>
        <div class="center">

                <h1 class="error">
                        <span>
                                <?php echo $this->error->getCode(); ?>
                        </span>
                </h1>
                <h2 class="title"><?php echo $this->error->getMessage(); ?></h2>
                <p class="message">The Page you are looking for no longer exists or another error occurred. <a href="javascript:history.go(-1)">Go back</a>, or head over to <a href="http://www.joellipman.com/">Joel Lipman .Com</a> to choose a new direction.</p>

        </div>
</body>
</html>
  1.  <?php 
  2.  /** 
  3.   * @package     Joomla 2.5.x - Clean Error Page 
  4.   * @copyright   Copyright (C) 2013 Joel Lipman .Com. All rights reserved. 
  5.   * @license     GNU General Public License version 2 or later; see LICENSE.txt 
  6.   */ 
  7.   
  8.  defined('_JEXEC') or die; 
  9.  if (!isset($this->error)) { 
  10.          $this->error = JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'))
  11.          $this->debug = false
  12.  } 
  13.  //get language and direction 
  14.  $doc = JFactory::getDocument()
  15.  $this->language = $doc->language; 
  16.  $this->direction = $doc->direction; 
  17.  ?> 
  18.  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  19.  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>"> 
  20.  <head> 
  21.          <title><?php echo $this->error->getCode()?> - <?php echo $this->title; ?></title> 
  22.          <style> 
  23.                  .error > span {position:relative;} 
  24.                  .error > span:before {content:"";position:absolute;top:70%;left:-30px;right:-30px;height:80px;background:url(/templates/system/images/error_shadow.png) no-repeat;background-size:100100%;} 
  25.                  .error {text-shadow:0 -1px 0 rgba(0,0,0,0.9), 0 1px 0 rgba(255,255,255,0.7);font-size:200px;font-weight:700;position:relative;top:50px;} 
  26.                  h1,h2,h3,h4,h5,h6 {color:#505050;font-weight:400;} 
  27.                  h1 {line-height:36px;font-size:2em;font-weight:700;} 
  28.                  .center {text-align:center;} 
  29.                  body {font:normal 14px/20px Arial, Helvetica, sans-serif;color:#777;} 
  30.                  .title {margin:20px 0 0;} 
  31.                  h2 {font-size:24px;line-height:24px;} 
  32.                  .message {width:400px;margin:20px auto 0;text-align:justify;} 
  33.          </style> 
  34.  </head> 
  35.  <body> 
  36.          <div class="center"> 
  37.   
  38.                  <h1 class="error"> 
  39.                          <span> 
  40.                                  <?php echo $this->error->getCode()?> 
  41.                          </span> 
  42.                  </h1> 
  43.                  <h2 class="title"><?php echo $this->error->getMessage()?></h2> 
  44.                  <p class="message">The Page you are looking for no longer exists or another error occurred. <a href="javascript:history.go(-1)">Go back</a>, or head over to <a href="http://www.joellipman.com/">Joel Lipman .Com</a> to choose a new direction.</p> 
  45.   
  46.          </div> 
  47.  </body> 
  48.  </html> 

Additional
IMPORTANT: After each update of the Joomla CMS, check that this file has not been overwritten as the Joomla update patches often reset this file.

Category: Joomla :: Article: 500

Credit where Credit is Due:


Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman
www.joellipman.com

Related Articles

Joes Revolver Map

Accreditation

Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin bc1qf6elrdxc968h0k673l2djc9wrpazhqtxw8qqp4

Ethereum:
Donate to Joel Lipman with Ethereum 0xb038962F3809b425D661EF5D22294Cf45E02FebF
© 2024 Joel Lipman .com. All Rights Reserved.