当前位置:Gxlcms > PHP教程 > Magento如何自定义404页面?

Magento如何自定义404页面?

时间:2021-07-01 10:21:17 帮助过:35人阅读

Magento修改404页面

Magento有默认的404页面,如果想自定义一个404页面,又该如何做呢?

方法一

首先,先来看下默认的404页面:

1.Magento的CMS部分,可以通过定义它来改变错误页面,登录后台admin->CMS->Pages:

2.打开404 Not Found页面,点击左侧的Content,就可以看到404页面的详情:

3.现在来重新定义下404页面,比如,输入以下代码:

  1. <code>
  2. <h3>D'oh! That page can't be found.</h3>
  3. <p><strong>Don't get angry, and don't cry.</strong> Let us
  4. take that burden. It's not your fault. No, really, listen to me.
  5. It's not your fault. We have a 24 hour hotline to deal with things
  6. just like this. Okay, its not really a hotline, its really
  7. just some encouraging words to keep trying, but hotline sounds
  8. so much .</p>
  9. <p>Sorry but the page you are looking for cannot be found.
  10. If you're in denial and think this is a conspiracy that cannot
  11. possibly be true,</p>
  12. <dl>
  13. <dt>Perhaps you are here because:</dt>
  14. <dd>
  15. <ul>
  16. <li>The page has moved</li>
  17. <li>The page is no longer exists</li>
  18. <li>You were looking for your puppy and got lost</li>
  19. <li>You like 404 pages</li>
  20. </ul>
  21. </dd>
  22. </dl>
  23. <dl>
  24. <dt>What can you do?</dt>
  25. <dd>Have no fear, help is near! There are many ways you can get back on track with Magento Demo Store.</dd>
  26. <dd>
  27. <ul>
  28. <li>Go back to the
  29. previous page.</li>
  30. CMS and Design
  31. 30
  32. <li>Use the search bar at the top of the page to search for
  33. your products.</li>
  34. <li>Follow these links to get you back on track!<br>Store Home<br>My
  35. Account</li>
  36. </ul>
  37. </dd>
  38. </dl></code>

4.点击save page,重新打开,可以看到404页面已经发生变化。

方法二

方法一,是通过在后台配置修改,除此之外,还需要知道的是,修改404页面,也可以通过修改模板来更改。

1.首先要将CMS中的404 Not Found 的状态改成disable。

2.找到 no-route.phtml页面,路径为app/design/frontend/base/default/
template/cms/default/no-route.phtml,打开,会看到如下代码:

  1. <code>There was no 404 CMS page configured or found.</code>

3.再次打开前台页面,查看是否与上述代码内容一致,前台页面为:

4.由此,可以通过修改模板文件来修改404页面。

以上就介绍了Magento如何自定义404页面?,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

人气教程排行