3

How do I create a custom error page (404) for Joomla 1.6?

I've tried a tutorial (http://docs.joomla.org/Tutorial:Create_a_Custom_404_Error_Page) but it's for 1.5 and it's not working.

Thank you.

3 Answers 3

1

The call to ->code is a call to a protected property, aka not possible any more. You have to use getCode(). The fixed code for 1.6 :

  if ($this->error->getCode() == '404') {
          header('Location: /index.php?option=com_content&view=article&id=214');
          exit;
  } ;

This works for Yoomla 1.6 now. ( as a fix for the 1.5 example on http://docs.joomla.org/Creating_a_Custom_404_Error_Page - the rest on this page is accurate)

0

I think i'd solve this with a more traditional approach and simply edit the .htaccess file.

I think this is also a more search engine friendly approach too.

For some creative

0

Just simply follow these steps:

  1. Create a Category (Uncategorized) (see if it’s not already there by default)
  2. Create an article
    • Title: 404
    • Category: Uncategorized
    • Article Content: Opps, Page not Found (or something else)
  3. Create a hidden menu
    • Menu -> Menu Manager
    • Title: Hidden, Menu Type: Hiddenmenu
  4. Create a menu item inside this Hidden menu
    • Menu Type: Single Article
    • Title: Page not found
    • Alias: page-not-found
    • Template: your template which you want to use to show that page not found
    • Link Article: to the article you have created in our case 404
    • Robots: no index; no follow (for google to avoid indexing this page)
  5. Then add this piece of code in your error.php of joomla you can find that inside (root_directory)\templates\system\error.php

    defined( '_JEXEC' ) or die( 'Restricted access');  if ($this->error->getCode() == '404' ) { header('Location: http://www.domain.com/page-not-found'); exit;}
    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.