Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating child CMS pages in Magento

I would like 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

Any ideas?

like image 737
Jason Avatar asked Aug 18 '10 19:08

Jason


People also ask

What are CMS pages in Magento?

Magento 2 CMS Pages are the set of your Magento 2 website pages used for distributing content. Magento 2 enables you to create CMS pages for different purposes or translate CMS pages for different locales. You can even restrict some CMS pages visibility for a certain group of customers.


1 Answers

You are right, there is no hierarchy of CMS pages in Magento. The best solution would be to create a real hierarchy by adding a parent_id to CMS pages and modifying the CMS module to handle nested URLs and breadcrumbs. But that requires a lot of coding.

A quick-and-dirty hack is to modify the breadcrumbs manually on each subpage by adding something like this to the layout update XML:

<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 page</label><title>Home page</title><link>/</link></crumbInfo>
    </action>
    <action method="addCrumb">
        <crumbName>myparentpage</crumbName>
        <crumbInfo><label>My Parent Page</label><title>My Parent Page</title><link>/myparentpage/</link></crumbInfo>
    </action>
    <action method="addCrumb">
        <crumbName>mysubpage</crumbName>
        <crumbInfo><label>My Sub Page</label><title>My Sub Page</title></crumbInfo>
    </action>
</block>
</reference>
like image 106
Anders Thirsgaard Rasmussen Avatar answered Oct 11 '22 19:10

Anders Thirsgaard Rasmussen