Return to Snippet

Revision: 17936
at September 17, 2009 06:30 by nico65


Initial Code
<reference name="root">
<action method="unsetChild"><alias>breadcrumbs</alias></action>
</reference>

<reference name="root">
<block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs">
    <action method="addCrumb">
        <crumbName>home</crumbName>
        <crumbInfo><label>Home</label><title>Go to Home Page</title><link>/</link></crumbInfo>
    </action>
    <action method="addCrumb">
        <crumbName>foo</crumbName>
        <crumbInfo><label>Foo</label><title>Foo</title><link>/foo/</link></crumbInfo>
    </action>
    <action method="addCrumb">
        <crumbName>cms_page</crumbName>
        <crumbInfo><label>Bar</label><title>Bar</title></crumbInfo>
    </action>
</block>
</reference>

Initial URL
http://www.lindenlan.net/2009/04/21/how-to-fake-a-magento-subpage/

Initial Description
agento, an open-source PHP ecommerce solution, has a very comprehensive feature list. However, its built-in CMS doesn’t support hierarchical pages. You can fake it, though.

Let’s say you have a page with an SEF (search engine friendly) URL Identifier of “foo”. You’d like to have a subpage “bar” nested under foo. The CMS doesn’t let you create parent-child relationships, but Magento will let you include forward slashes in the SEF URL Identifier so that it is “foo/bar”.

That’s the good news. The bad news is if you want to use the breadcrumbs block, it won’t work out of the box. The Magento CMS is flat, so the default breadcrumbs will always look like “Home / My Page Title.” The optimal solution is to override the breadcrumbs module and parse the SEF URL Identifier and construct the breadcrumbs from that. (I may write a post about it in the future so stay tuned.) The good news for those designers out there, you don’t have to dive into code.

Magento’s CMS has a feature where each page has a way to override its XML layout. When you’re editing a page, go to the “Custom Design” tab. There you’ll see a form field called “Layout Update XML”. This is the key. Here’s where you add XML to first unset the breadcrumbs block and then add it back in but with your specific breadcrumbs. Here’s the code:

Initial Title
How To Fake a Magento Subpage

Initial Tags
magento

Initial Language
PHP