Thursday, July 24, 2014
   
Text Size
Login

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/elephants.
  • 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.

  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: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"> 
  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.

Add Comment

Name:

Email:

Website:

Message:


Latest Posts

  • Joes Quicklist Weblinks (JQW)

    • Thu 17-Jul-14
      Hi, thanks a lot. But I have got a problem with download it. Error: "File could not be found Important!
      Kat  
    • Tue 15-Jul-14
      Hi Artur, I forgot to get back to you sooner. I was going to include a set of instructions to do this ...
      Webmaster  
    • Mon 14-Jul-14
      Hi Skarosg, Not sure if we took this to e-mail but I noticed your site is displaying the images now.
      Webmaster  
    • Fri 11-Jul-14
      Hi, How can I put user name and category of weblink in module, near the date? Thanks..
      Artur
  • Joes Word Cloud (JWC)

    • Tue 17-Jun-14
      I'm using JE 3.1.19 stable.
      alve89