This one might be greek to people who haven’t read No Frills Magento Layout, but I’d like it spelled out so I don’t have to think about it again. (If you don’t own a copy, there are worse ways to learn Magento).
When Magento is loading handles from the Layout Update XML Files into the package layout, these updates are loaded into an internal array, handle by handle. All the handles from one file are loaded, and then handles from the next file are loaded. The core.xml
file is first, the page.xml
file is second, etc. This ordering will be significant.
More significant is the order of the handles.
default
STORE_default
foo_baz_index
customer_logged_out
When generating the Page layout, the Layout_Update
object searches through the Package layout, by handle. This means (in the above example) all the default
handles are loaded first, then the STORE_default
, etc.
The local.xml
Layout Update XML File is always loaded last. That’s to ensure a store developer has a simple place to put all their layout updates that will ensure they’re loaded last and “win” over core layout updates. However, just because the updates in local.xml
are loaded last does not mean that any update added to local.xml
will run after an update in another file.
An update added with a <default>
handle in local.xml
will run before an update added with a STORE_default
handle in page.xml
. (The page.xml
is the first file loaded).
That’s because, irrespective of the file they’re in, default
handles are all added to the Page layout first, which means their meta-code will run first.