Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the "update" element do in Magento layout XML?

Tags:

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?

like image 802
pancake Avatar asked Oct 05 '11 12:10

pancake


People also ask

What is the use of update handle in Magento 2?

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.

How do I change the layout of a product detail page in Magento 2?

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.

How do I change the layout of a category list in Magento 2?

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.


1 Answers

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".

like image 166
vzwick Avatar answered Nov 22 '22 04:11

vzwick