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

你离开我真会死。 提交于 2019-12-07 15:57:40

问题


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.


回答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)




回答2:


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




回答3:


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;}
    


来源:https://stackoverflow.com/questions/5016672/how-do-i-create-a-custom-error-page-404-for-joomla-1-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!