Magento – creating custom breadcrumbs for CMS pages

breadcrumb

I wanted to create a subordinate set of CMS pages in Magento so that the breadcrumb navigation at the top of the page looks like this:

Home > Parent CMS Page > Child CMS Page

Even though I can specify a hierarchical relationship with the URL key field, it seems to be that all CMS pages in Magento are listed in the root directory by default:

Home > Child CMS Page

To override the default, you have 2 options :

1. Update CMS page layout: you must insert a bit of XML code into the CMS page’s Design > Page Layout > Layout Update XML field:


<reference name="root">

<action method="unsetChild"><alias>breadcrumbs</alias></action>

<block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs">

<action method="addCrumb">

<crumbName>Home</crumbName>

<crumbInfo><label>Home</label><title>Home</title><link>/</link></crumbInfo>

</action>

<action method="addCrumb">

<crumbName>Parent CMS Page</crumbName>

<crumbInfo><label>Parent CMS Page</label><title>Parent CMS Page</title><link>/parent-cms-page</link></crumbInfo>

</action>

<action method="addCrumb">

<crumbName>Child CMS Page</crumbName>

<crumbInfo><label>Child CMS Page</label><title>Child CMS Page</title></crumbInfo>

</action>

</block>

</reference>

2. Extend Magento breadcrums functions to make it use hierarchy (from Magento EE version)

… will be updated shortly 😀

1 Comment

Leave a Comment