What is the difference between remove and unsetChild methods in layout?

What is the difference between remove and unsetChild methods in layout?

For example (in poll.xml layout file):

<customer_account_index>
    <reference name="right">
        <action method="unsetChild"><name>catalog_compare_sidebar</name></action>
    </reference>
</customer_account_index>

Why unsetChild and not just remove?

What is the difference between linear and relative layout?

What is the difference between linear and relative layout?

R: what is the difference between rm and remove?

What is the difference between rm and remove?

Angular $resource: what is the difference between delete and remove?

What is the difference between delete and remove methods? Both of them use DELETE method of HTTP. I couldn’t find any reasonable information.

What is the difference between methods “insert subview” and “presentModalViewController”?

What is the difference between those two methods when it comes to changing the nib views?

What is the difference between KineticJS draw methods?

What is the difference between KineticJS methods layer.draw(), layer.drawScene() and layer.drawHit()?

What is the difference between all these Auto Layout update methods? Are all necessary?

In the code below, these four methods are called for layout reasoning. I’m a little confused why all of them are needed, though, and what they do differently from one another. They’re used in the proc

What is the difference between class and instance methods?

What’s the difference between a class method and an instance method? Are instance methods the accessors (getters and setters) while class methods are pretty much everything else?

What’s the difference between Delete and Remove in a many-to-many relationship in CoolStorage

A many-to-many relationship has to methods to remove items: Delete and Remove. What is the difference between these two?

what is the difference between layout and android:layout

i am new to android and would like to know the difference between specifying layout and android:layout .can they be used interchangeably <include [email protected]/one> <ViewStub android:layo

difference between ‘detach’ and ‘remove’ entityManager’s methods

I would like to know what’s the real difference between em.detach(entity), em.remove(entity) and using a JPQL request like : em.createQuery(DELETE FROM Country).exceuteUpdate(); thanks.

Answers

Remove nodes will be processed after all layout handles are merged, and are a good way to remove a block regardless of which layout handle loaded the block; you just want to get rid of it entirely for some handles! It also removes recursively, so all you need to specify is the layout handle.

On the other hand, you may only want to remove a block from a reference in a specific layout handle, in which case you should use unsetChild. It is often used to remove a block from a reference, but then re-insert the same block with a different position. This would not have been possible with remove.

In your very specific example, the magento developers used it to give magento some flexibility. Let’s say I added a subpage for the account index page, and the following layout handles were loaded:

  • default
  • customer_account_index
  • customer_account_index_subpage

And now assume on this subpage I would actually want the ‘catalog_compare_sidebar’ block. If they had used ‘remove’, I would not be able to add this block (with this specific name) because ‘remove’ would be processed -after- I had added the block myself.

This allows you to easily make changes from one single file; local.xml.

Taking your code as an example,if you use unsetchild,compare sidebar block removed from right column,but you can use it anywhere like left column,footer etc..,remove removes entirely from the template,and cannot be used anywhere.

Remove the compare sidebar using remove and if you call it somewhere else,error will be thrown.