Tuesday, March 03, 2015
Text Size

Change the default Joomla Error template

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/elephants.
  • Applies to Joomla 1.6.x, 1.7.x, 2.5.x

  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.

  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.   */ 
  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:100% 100%;} 
  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"> 
  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> 
  46.          </div> 
  47.  </body> 
  48.  </html> 

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.

Add Comment





Help Develop!

Thank You! :c)

Connect: Google+

Visitors of the World

Latest Posts

  • Basic Android App using Google Maps and Current Location

    • Wed 25-Feb-15
      SOrry ive solved the previous error but having an error context.LOCATIO N_SERVICE);
    • Wed 25-Feb-15
      Hi im getting an error getLastKnownLocation(provider) can not resolve provider any hekp
  • JDatabase: using the Joomla database with examples

    • Sat 28-Feb-15
      High Praise, Thx Scott! I still use this for myself, nice to know it was of some use to you.
      Joel L.  
    • Fri 27-Feb-15
      Wow, thank you so much, Joomla documents are written for those who can read Joomla documents. :lol: Your ...
      Scott N.  
    • Thu 26-Feb-15
      Clearly represented jfactory querys. This helped me a lot. Thank you very much. :-)