1

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.

  • See here in details inchoo.net/magento/… – Abdul Jun 30 '16 at 4:44
  • @Abdul the article doesn't answer the question and is a bit outdated (2010, way before Magento introduced theme inheritance with 1.9) – Fabian Schmengler Jun 30 '16 at 6:29
3

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>
  • My purchased theme didn't use a theme.xml file, so it should have been straightforward (thanks to your help!) Unfortunately I did have some trouble. The theme had its own child theme that it required I set as the default in the system config, so folder structure theme/default and theme/main, with "main" set as the default in config. When I added theme/mychild/etc/theme.xml it would break the theme as I can only set the parent to 'main' or 'default'. I solved this by setting my parent to 'main' and creating theme/main/etc/theme.xml declaring default as its parent. – OffTheRadar Jul 1 '16 at 3:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.