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

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.