Magento: relationship between template files and the layout XML file
I see that the callouts template开发者_Go百科 (files in frontend\my_package\default\template\callouts) doesn't have a corresponding layout XML file (frontend\my_package\default\layout). So, I thought if I have a blank layout XML file at frontend\my_package\default\layout\callouts.xml, this will disable the callout block on the Magento front page. However, it doesn't work.
The checkout template does have a checkout.xml layout file, so making this a blank file removes the checkout out block from the page I'm looking at. For the checkout block case, does the checkout.xml override what is called from the active catalog.xml? I don't remove the corresponding lines from catalog.xml, but the blank checkout.xml file will disable this block regardless.
I know that removing corresponding lines for whatever blocks in catalog.xml removes/doesn't load what I want on the web page, but I'd like to find out why my attempt to "override" callouts isn't working. TIA!
Note: I already have caching disabled.
The short version: All those XML files are merged into one giant XML file. Then, during each request, the XML inside certain top level tags (<default>, <catalog_category_index>, etc.; there tags are called handles) are selected, and merged into a smaller XML file. The nodes left in the smaller XML file are a set of instructions to create certain blocks. Each (well, most) block has a phtml template file. When you add stuff to local.xml
, you're saying "in addition to the normal stuff, do this extra stuff". When you replace an entire file like catalog.xml
, you're saying "us my file instead", ignore the stuff you normally do.
If you're interested in the long version read No Frills Magento Layout, my DRM free PDF on the Magento layout system.
One solution to 'overriding' callouts would be this:
/app/design/frontend/base/default/layout/local.xml
<layout version="0.1.0">
<default>
<remove name="left.permanent.callout" />
<remove name="right.permanent.callout" />
</default>
</layout>
NB: Alan's answer covers everything else in your question though.
精彩评论