3

According to this article http://alanstorm.com/magentos_many_404_pages/ there is three 404 pages in Magento: 1 The one dispatched by the apache 2 CMS page 3 Generated via layout XML

If I need to create my own distinct 404 page, that has different design from default Magento 404, the best way is probably 'Adding custom Layout XML Updates to the handles cms_index_noroute and cms_index_defaultnoroute', right?

What I did:

1 New module

2 <frontend> <layout> <updates> <mine_eshop> <file>mine/eshop.xml</file> </mine_eshop> </updates> </layout> </frontend>

3

<cms_index_defaultnoroute>
    <remove name="right"/>
    <remove name="left"/>

    <reference name="content">
        <block type="core/template" name="mine_no_route" template="mine/404.phtml"/>
    </reference>
</cms_index_defaultnoroute>

And now I got my custom template right below the default one. And this is inside default Magento page layout.

There was no 404 CMS page configured or found.

New 404

How to display only the custom 404.phtml on the page in case of that error? They say there is no 'right' way to do it and it is pretty frustrating. What are the best practices of creating a custom error pages?

3

You can change it via configuration but if you want to replace the template file then I would do it via local.xml instead.

Create local.xml if you don't have in your theme's layout folder and add this:

<?xml version="1.0"?>
<layout version="0.1.0">
    <cms_index_defaultnoroute>
     <reference name="default_no_route">
         <action method="setTemplate">
             <template>your/path/to/no-route-file.phtml</template>
         </action>
     </reference>
    </cms_index_defaultnoroute>
</layout>

This will replace the template for no route AKA 404 page. I haven't tested but should work. Good luck.

0

You can just customize the default '404 Not Found' page under CMS -> Pages in your Magento admin. If it's not there, create a new cms page and select it in System -> Configuration -> General -> Web -> Default Pages -> CMS No Route Page.

  • This will give me a poor CMS page surrounded by a default Magento page layout. And I need an entirely new page. – TheKitMurkit May 16 '17 at 11:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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