2

I'm trying my best to understand more about the local.xml file. If I may, could some kind soul answer a couple of questions I have?

  1. As I understand it, Magento will only read one local.xml file when rendering the page? I think this is true, because I just created a blank local.xml file in my child theme and the site was completely broken as a result.
  2. I use the Ultimo theme and I can see in the file directory that it uses it's own local.xml file, located at: app/design/frontend/ultimo/default/layout. If I was to modify this local.xml file, will the changes get overwritten when I update the theme? Updates for Ultimo are common and presumably this file gets modified now and again by the developers?

Thanks for taking the time to read this. Magento is fascinating to use but also very complicated for us beginners.

  • 3
    "very complicated for us beginners" - Understatement of the year. It took years of working with Magento before I finally started feeling "Oh, I get it. Okay, I just do this..." – Tyler V. Feb 3 '15 at 19:59
2

My understanding is that yes, only one local.xml will be read. But that doesn't mean that your child theme can't make changes. My suggestion is to carefully read this great article by Alan Storm on theme inheritance. While it's not totally required that you install the module that is mentioned in the article, I've used it to great effect to have a child of a child of a child theme in a large Magento site.

  • Thanks for providing that link. I am enjoying all of your answers now. :-) +1 for this. – Rajeev K Tomy Feb 4 '15 at 2:55
2

Magento is using theme fall back mechanism to locate a theme specific file (either layout update files or template files).

Suppose your package and theme are configured as below

Theme-Fallback

Now magento will look for local.xml file in the following order

Package/Theme                             Location
__________________________________________________________________________________________
mypackage/mytheme   app/design/frontend/mypackage/mytheme/layout/local.xml
                    [app/design/frontend/mypackage/mytheme/template/{path-to-a-template-file}
                    skin/frontend/mypackage/mytheme/{path-to-a-resourece}]

mypackage/default   app/design/frontend/mypackage/default/layout/local.xml
                    [app/design/frontend/mypackage/default/template/{path-to-a-template-file}
                    skin/frontend/mypackage/default/{path-to-a-resourece}]

base/default        app/design/frontend/base/default/layout/local.xml
                    [app/design/frontend/base/default/template/{path-to-a-template-file}
                    skin/frontend/base/default/{path-to-a-resourece}]

As you can see, magento will first look into mypackage-mytheme section first for local.xml file. If it finds one, then use it and fallback mechanism ceases. If it couldn't find local.xml file there, then it will look into mypackage-default section. If finds, then use that otherwise fallback mechanism continues to base-default section. This is the end location. If it cant find a file with name local.xml, then magento simply ignores it. However this fallback mechanism is used between magento-1.4 -> magento-1.8

From magento-1.9, fallback mechanism slighly changed. It now uses infinite fallback mechanism which will give a chance to fallback into any number of theme levels. For more details, you can look into alanstorm article

In short, from magento-1.9, theme fallback works like below. Let us assume you have 4 custom packages

package1/theme1
package1/theme2
package2/theme3
package3/theme4

Now suppose

package3/theme4 is a child of package2/theme3 is a child of packag1/theme2 is a child of package1/theme1 is a child of rwd/default

** Yes, from magento-1.9 we can set a parent theme for another theme. This is done via a special file called theme.xml

Assume you are using package3/theme4 in your application. Now magento look for local.xml like in the follwing order

package3/theme4    app/design/frontend/package3/theme4/layout/local.xml
package2/theme3    app/design/frontend/package2/theme3/layout/local.xml
package1/theme2    app/design/frontend/package2/theme2/layout/local.xml
package1/theme1    app/design/frontend/package1/theme1/layout/local.xml
rwd/default        app/design/frontend/rwd/default/layout/local.xml

This is known as infinite fallback mechanism since as the themes become depending on another theme, then fallback mechanism also grow up !!!

Hope that will give you a good idea.

  • This is a great answer! – Liam McArthur Sep 22 '17 at 15:09
  • @LiamMcArthur Great to hear that!!! – Rajeev K Tomy Sep 22 '17 at 17:42

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.