What is the difference between
<action method=”unsetChild”> and
Both functions are used to remove a block from the layout.
Could someone explain with an example?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.Sign up to join this community
<remove name="" /> operates in the global block scope of
Mage_Core_Model_Layout. These are collected in
Mage_Core_Model_Layout::generateXml() and used to prevent the block with the specified name from even being instantiated. Also, any child blocks declared for a
<remove />ed block will also not be instantiated.
<action method="" /> a.k.a
Mage_Core_Block_Abstract::unsetChild() is a block-level method which de-lists the indicated child block (by alias, not by name) from the parent block instance on which the action is being called. This most often results in the block "disappearing" from the rendered output, even though the block instance is still created. Used in combination with the
::insert() methods, it is used to perform a "move".
<remove name="" /> ,When finished with all layouts, Magento will completely delete the block with indicated name="", regardless of which layout handle it has been added to. Using this method it is impossible to remove a block from one location and then add it to another
<action method="unsetChild"> operates only in the context where it is being used. unsetChild is created for moving existing blocks from one place to another. You need to use this method if you want to remove a specific block from a specific layout handle and then insert it to another position or layout handle.