Right now I'm exploring the internals of the admin section of Magento and I stumbled on this piece of XML:
File: app/design/adminhtml/default/default/layout/catalog.xml
, around line 55
50 <block type="core/template" template="catalog/wysiwyg/js.phtml"/> 51 </reference> 52 </adminhtml_catalog_product_new> 53 54 <adminhtml_catalog_product_edit> 55 <update handle="editor"/> 56 <reference name="content"> 57 <block type="adminhtml/catalog_product_edit" name="product_edit"></block> 58 </reference>
What does the <update />
tag do?
Object-specific Layout Update Handles. Every HTTP request in Magento results with a few layout handles which can be used to customize layout of desired pages. If you ever tried to dump layout handles in Magento, you would see many of them. These handles are calculated differently, based on different variables.
In order to apply custom layout updates for your product pages, you'll need to put an . XML file in a specified folder ( app/design/frontend/<Vendor>/<Theme>/Magento_Catalog/layout/ ). The layout update from that . XML file will then appear under Custom Layout Update as a selectable option.
To change the category layout, go to Products -> Categories -> Select your desired Category go to the Design tab and select desired option from the Layout dropdown.
The <update>
basically pulls in another handle.
Assume you have this:
<layout> <foo> <reference name="header"> <block type="cms/block" name="some_block" as="someBlock"> <action method="setBlockId"><block_id>some_block</block_id></action> </block> </reference> <reference name="left"> <block type="cms/block" name="some_totally_different_block" as="someTotallyDifferentBlock"> <action method="setBlockId"><block_id>some_totally_different_block</block_id></action> </block> </reference> </foo> <bar> <update handle="foo" /> <reference name="header"> <block type="cms/block" name="some_other_block" as="someOtherBlock"> <action method="setBlockId"><block_id>some_other_block</block_id></action> </block> </reference> </bar> </layout>
The resulting XML for bar
would be:
<layout> <bar> <reference name="header"> <!-- Start of part pulled in from foo --> <block type="cms/block" name="some_block" as="someBlock"> <action method="setBlockId"><block_id>some_block</block_id></action> </block> <!-- End of part pulled in from foo --> <block type="cms/block" name="some_other_block" as="someOtherBlock"> <action method="setBlockId"><block_id>some_other_block</block_id></action> </block> </reference> <!-- Start of part pulled in from foo --> <reference name="left"> <block type="cms/block" name="some_totally_different_block" as="someTotallyDifferentBlock"> <action method="setBlockId"><block_id>some_totally_different_block</block_id></action> </block> </reference> <!-- End of part pulled in from foo --> </bar> </layout>
tl;dr: The update
handle is basically a "merge this layout with my current layout".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With