When I create a layout file for the admin area (whether in the community or local code pool), sometimes Magento is loading that layout xml in before the Adminhtml module layout xml is loaded. The effect is that reference calls are discarded because there is no block created to apply them to.
Obviously, caching is not playing a part here. I have added Mage_Adminhtml
in the <depends/>
node in the module declaration file.
Is this an issue that you have had before? If so, how is it resolved?
I have worked through this issue a number of times, and get to a solution each time, but I can't figure what causes this to happen in the first place.
Best Answer
It's hard to say without a concrete example, but I suspect you're running into a file order vs. handle order problem.
Specifically, Magento loads its XML files in module order, with
local.xml
tacked on last. Here's a typical list, in orderThe order layout XML files are loaded in dictates the order layout XML rules are applied — per handle. It's this last part that trips people up. Handles are those top level XML nodes.
Handles are sort of like events for the layout — for every page request Magento issues a number of handles. You can use Commerce Bug to see which handles are issued for a particular page request
For those with images turned off, the handles issued for that particular page request were
What this means is, Magento will run every
default
XML chunk: first for thecore.xml
file, then everydefault
chunk for thepage.xml
file, all the way down tolocal.xml
.Then, Magento will run every
catalog_category_layered_nochildren
XML chunk: first for thecore.xml
file, then for thepage.xml
file, all the way down tolocal.xml
.This continues for each handle.
What this means is, if you have a bit of layout update XML in
local.xml
inside adefault
handle, it will run before a bit of layout update XML incore.xml
that's inside thecatalog_category_layered_nochildren
handle. This is, by far, the thing that causes the most confusion in the layout XML system, especially since there's a bit of conventional wisdom floating around that says "local.xml loads last".If the above confused you a bit and you need to learn more about the Layout XML system, I still think my book No Frills Magento Layout is the best way to learn the system inside out.