Take the 2-minute tour ×
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It's 100% free, no registration required.

what is the difference between <action method=”unsetChild”> and <remove name=""/>

both function is used to remove the block.

Could some one explain with example.

share|improve this question
add comment

2 Answers

up vote 10 down vote accepted

<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 ::append() or ::insert() methods, it is used to perform a "move".

share|improve this answer
add comment

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

share|improve this answer
    
Not quite; see my answer for corrections. –  benmarks Feb 6 at 19:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.