Magento 1.9 – Layout Updates in theme.xml to Pick Up Parent Theme’s XML

layoutmagento-1.9parent-child-theme

I've created a theme package called hoi with a default theme. In the app/design/frontend/hoi/default/etc/theme.xml I've set a parent theme to be the a theme we purchased called blacknwhite.

This almost works but it does not pick up the layout.xml from the blacknwhite theme as my own theme's xml overwrites it. It works when I copy and paste the contents from the blacknwhite theme's xml into my own theme's xml. But I would rather not do this as so I tried to create a new layout update in my theme's theme.xml.

theme.xml

<theme>
    <parent>blacknwhite/default</parent>
    <layout>
        <updates>
            <hoi_default>
                <!--should be linking to app/design/frontend/hoi/default/layout/parentslocal.xml-->
                <file>hoi/parentslocal.xml</file>
            </hoi_default>

            <hoi_default>
                <!--should be linking to app/design/frontend/hoi/default/layout/local.xml-->
                <file>hoi/local.xml</file>
            </hoi_default>
        </updates>
    </layout>
</theme>

This way I hoped to have my own local.xml for my theme which would fall back onto a parentslocal.xml which I would then copy the contents of the parents local.xml to. But it's not working.

I tested it by putting the below in my local.xml but it did not work.

<layout version="0.1.0">
    <default>
        <reference name="header">
            <remove name="cart_sidebar"/>
        </reference>
    </default>
</layout>

I would have thought Magento would inherit from it's parent's theme more seamlessly.

I'm thinking it is perhaps better off putting my sub theme in blacknwhite/hoi!

Best Answer

I found the problem was with my syntax, as per Alan Storms post on infinite theme's fallaback the proper syntax is:

<?xml version="1.0"?>
<theme>
    <parent>rwd/enterprise</parent>
    <layout>
        <updates>
            <my_new_file_name>
                <file>my_new_file_name.xml</file>
            </my_new_file_name>
        </updates>
    </layout>
</theme>

So in my case this meant I needed:

<theme>
    <parent>blacknwhite/default</parent>
    <layout>
        <updates>
            <parentslocal>
                <!--should be linking to app/design/frontend/hoi/default/layout/parentslocal.xml-->
                <file>parentslocal.xml</file>
            </parentslocal>
        </updates>
    </layout>
</theme>
Related Topic