Local.xml packages are not loaded when custom theme is active from local.xml

I have a design package from ThemeForest that works pretty well, but I'm trying to create a new custom theme that consists of a stylesheet custom.css

and a layout file local.xml

that only adds a link to custom.css

.

In Magento Admin, the System> Configuration> General> Build / Package / Current package name is set to the development package I installed. This works fine until I installed Design / Themes / Default into my new custom theme, which causes the local.xml

design package file to be ignored . I can test this by deleting local.xml

my custom theme or replacing it with one from the design pack.

The same happens when I install Design / Themes / Layout to a different theme, now it is a local.xml

file from the package and one from Design / Themes / Default is ignored. I could work around this problem by merging the contents of all files local.xml

into one single under Design / Themes / Layout , but this is obviously not a desirable solution.

I've done custom themes before, but this is the first time I've had this problem. Anyone have a solution?

+3


source to share


1 answer


Problem

You are facing a limitation Magentos design canceled the hierarchy . The way it works is to search backward from the most specific location to the least specific.

... if your custom theme calls a CSS file named "styles.css" but the Magento application cannot find the file in your custom theme, Magento will navigate to the next topic in the hierarchy to find the file ... it will continue through the theme hierarchy until it can find a file named "styles.css".

This method of building the design is called rollback because the application "falls back to the next possible source of required files to retrieve and download the requested file.

For you, this means that the layout file local.xml

can only be obtained from one location, and it will be the one that most closely relates to the current theme. Therefore Magento will look for it in the following priority:

  • app/design/frontend/$package/$theme/layout/local.xml

  • app/design/frontend/$package/default/layout/local.xml

  • app/design/frontend/base/default/layout/local.xml

It is important to understand that each of these files overrides the next rather than adding to them. I heard that Magento 2.x can solve this situation, but for 1.x we need to work around it.

Possible Solution

The way I solved it was to create a simple extension that would just load your own css file into a separate layout file. Then you don't need the file local.xml

in your new theme and it will keep coming back to default

.



applications / etc / modules / My_Theme.xml

<?xml version="1.0"?>
<config>
    <modules>
        <My_Theme>
            <active>true</active>
            <codePool>local</codePool>
        </My_Theme>
    </modules>
</config>

      

App / code / local / my / theme / etc. /config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <My_Theme>
            <version>0.1.0</version>
        </My_Theme>
    </modules>
    <frontend>
        <layout>
            <updates>
                <my_theme>
                    <file>my_theme.xml</file>
                </my_theme>
            </updates>
        </layout>
    </frontend>
</config>

      

app / design / interface / $ package / $ Theme / layout / my_theme.xml

<?xml version="1.0"?>
<layout version="0.1.0">
    <default>
        <reference name="head">
            <action method="addCss"><stylesheet>css/my_theme.css</stylesheet></action>
        </reference>
    </default>
</layout>

      

The Magentos return method is used to consume the file. So you can put it in skin/frontend/$package/$theme/css/my_theme.css

or in a subdirectory $package/default/css/

.

+4


source







All Articles