Magento – local theme layout XML file other than local.xml

layoutmagento-1parent-child-themethemetheme-fallback

I've built a theme by creating and editing the following file:

frontend/mypackage/default/layout/local.xml

I have a store view "site1", and wish to make exceptions on the default local.xml of "mypackage", so I created this file:

frontend/mypackage/site1/layout/local.xml

However, as soon as I create this file, Magento skips the default local.xml changes.

How do I tell Magento to use the local.xml from default, and add the changes in site1's local.xml to that?

Best Answer

Since Magento 1.9 you can add custom layout updates in etc/theme.xml like this:

<theme>
    <layout>
        <updates>
            <my_theme>
                <file>my_theme.xml</file>
            </my_theme>
        </updates>
    </layout>
</theme>

If you define your theme specific layouts like this instead of using local.xml, it is easy to add another update in the child theme.

Unfortunately, the same problem goes with theme.xml that only the one from your actual theme is used, not the one from parent themes. But there is much less duplication.

Example theme.xml for the child theme:

<theme>
    <layout>
        <updates>
            <my_theme>
                <file>my_theme.xml</file>
            </my_theme>
            <my_child_theme>
                <file>my_child_theme.xml</file>
            </my_child_theme>
        </updates>
    </layout>
</theme>

Source and more info: http://alanstorm.com/magento_infinite_fallback_theme_xml