Magento修改404頁面
Magento有預設的404頁面,如果想自訂404頁面,又該如何做呢?
方法一
首先,先來看下預設的404頁面:
1.Magento的CMS部分,可以透過定義它來改變錯誤頁面,登入後台admin->CMS->Pages:
2.開啟404 Not Found頁面,點選左邊的Content,就可以看到404頁面的詳情:
3.現在來重新定義下404頁面,例如,輸入以下程式碼:
<code><div> <h3>D'oh! That page can't be found.</h3> <p><strong>Don't get angry, and don't cry.</strong> Let us take that burden. It's not your fault. No, really, listen to me. It's not your fault. We have a 24 hour hotline to deal with things just like this. Okay, its not really a hotline, its really just some encouraging words to keep trying, but hotline sounds so much .</p> <p>Sorry but the page you are looking for cannot be found. If you're in denial and think this is a conspiracy that cannot possibly be true,</p> </div> <dl> <dt>Perhaps you are here because:</dt> <dd> <ul> <li>The page has moved</li> <li>The page is no longer exists</li> <li>You were looking for your puppy and got lost</li> <li>You like 404 pages</li> </ul> </dd> </dl> <dl> <dt>What can you do?</dt> <dd>Have no fear, help is near! There are many ways you can get back on track with Magento Demo Store.</dd> <dd> <ul> <li><a href="#">Go back</a> to the previous page.</li> CMS and Design 30 <li>Use the search bar at the top of the page to search for your products.</li> <li>Follow these links to get you back on track!<br /><a href="/">Store Home</a><br /><a href="/customer/account/">My Account</a></li> </ul> </dd> </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,打開,會看到如下程式碼:
<code>There was no 404 CMS page configured or found.</code>
3.再次開啟前台頁面,查看是否與上述程式碼內容一致,前台頁面為:
4.由此,可以透過修改範本檔案來修改404頁面。
以上就介紹了Magento如何自訂404頁面? ,包括了方面的內容,希望對PHP教程有興趣的朋友有所幫助。