Domanda

I'm in the process of converting my company's web site to Magento 1.9. We've purchased a theme, but need to make some design changes such as adding javascript and css files to the header.

I'm new to Magento, but I believe that the changes we need to make would typically be made by modifying the local.xml file of the theme. My purchased theme, however, already has a very detailed local.xml. I'm hesitant to modify this because I assume it's likely to change if the theme is updated. I've tried overriding the layout under Config->Design->Themes->Layout, but when I create my own local.xml, of course the primary file is never loaded.

Is it possible for my overridden local.xml to indicate that the parent file should be ran as well? Or is there a better way to accomplish what I'm trying to do in general? I believe I could create a module that applies our layout changes, but that doesn't seem like the "right" way to do it.

È stato utile?

Soluzione

Is it possible for my overridden local.xml to indicate that the parent file should be ran as well?

No. Unfortunately for local.xml the same fallback mechanism applies as for all other theme files, i.e. the first one in the theme inheritance tree is used and there is no way to include a parent explicitly.

Or is there a better way to accomplish what I'm trying to do in general?

Yes, but it's still not ideal. Since Magento 1.9 you can use theme.xml for layout updates and it is actually the preferred way over local.xml. (Read more: https://erfanimani.com/dont-use-local-xml/)

If the purchased theme uses only local.xml and no layout updates in theme.xml, you can use theme.xml for your own changes. But note that theme.xml is loaded before local.xml, so if the order of actions matters, this might not work for you.


What if the parent uses theme.xml for layout updates as well? Now, the layout updates of parent theme.xml files are not loaded either, but since theme.xml works different than local.xml, there is a fix for that: https://github.com/ericthehacker/magento-themefallbackfix

And there is another option, which is probably the "right" way: You can also define layout files in theme.xml. You'll still need to copy these definition for child themes but that's only a few lines.

Example

mytheme/default/etc/theme.xml

<theme>
    <parent>base/default</parent>
    <layout>
        <updates>
            <mytheme_default><file>mytheme_default.xml</file></mytheme_default>
        </updates>
    </layout>
</theme>

mytheme/child/etc/theme.xml

<theme>
    <parent>mytheme/default</parent>
    <layout>
        <updates>
            <mytheme_default><file>mytheme_default.xml</file></mytheme_default>
            <mytheme_child><file>mytheme_child.xml</file></mytheme_child>
        </updates>
    </layout>
</theme>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange
scroll top