Magento Layout XML – Difference Between and Handle

layoutxml

I am bit confused in this two handle like when to use this two tags. Please clearfy for me like when to use this two.

Best Answer

Reference

This is used to make a reference to an current existing block in the layout xml. Say you want to change a template of a block you would first reference it and then call set template. Or if you wanted to add some new javascript to the header.

<reference name="head">
    <action method="addJs">
        <script>something/new.js</script>
    </action>
</reference>

Update

This is used to add a complete layout handle inside another one. For example if you had the layout handle test_handle and wanted to include the handle catalog_product_view you would do the following.

<test_handle>
    <update name="catalog_product_view" />
</test_handle>

In this case the test_handle and the catalog_product_view handle would be exactly the same and include the same blocks.