Update: Turns out the previous post was missing a <layout>
tag in the code examples. This has been fixed, and we regret the error. (Thanks to Bartosz Cisek, proprietor of brillan.pl, for the correction)
I was surprised to discover I hadn’t covered this anywhere other than No Frills Magento Layout.
The XML files in a theme’s layout folder
[package]/[theme]/[layout]
are Layout Update XML files. They’re all loaded into a single file called the design package.
If you want to add your own XML file, you’ll need to add a Magento module. Once you’ve added a module to the system, you’ll need to configure the name of the Layout Update XML file you’d like added.
To do this, first add the following node to your module’s config.xml
file.
<config>
<!-- ... -->
<frontend>
<layout>
<updates>
</updates>
</layout>
</frontend>
</config>
The <updates>
node is where you configure the XML files Magento will load the design package. Next, add a uniquely named node that identifies your update
<config>
<frontend>
<layout>
<updates>
<packagename_modulename>
</packagename_modulename>
</updates>
</layout>
</frontend>
</config>
If you use a node name already in use by another Magento module (ex. <catalog/>
), one node will get lost in the shuffle. Finally, add a <file/>
node to specify which file you’d like loaded
<config>
<frontend>
<layout>
<updates>
<packagename_modulename>
<file>packagename_modulename.xml</file>
</packagename_modulename>
</updates>
</layout>
</frontend>
</config>
Magento will now look for a packagename_modulename.xml
and if found, include its updates in the design package.
If you need to add an XML update file to the admin console application, you’ll want everything located under the <adminhtml/>
node
<config>
<adminhtml>
<layout>
<updates>
<packagename_modulename>
<file>packagename_modulename.xml</file>
</packagename_modulename>
</updates>
</layout>
</adminhtml>
</config>