Friday, November 29, 2013

Magento : Dynamically adding and changing blocks

Store-specific handle:
<STORE_#> (where '#' is the store ID — if you only have one store it is most likely '1')

Category-specific handle:
<CATEGORY_#> (where '#' is the ID number of the current category)

Product-specific handle:
<PRODUCT_#> (where '#' is the ID number of the current product)

Product type-specific handle:
<PRODUCT_TYPE_NAME> (where 'name' is the product type, example: 'simple', 'grouped', 'configurable', etc.)

Customer logged in or out:
<CUSTOMER_LOGGED_STATUS> (where 'status' is either 'in' or 'out')

If CMS page:
<cms_page>

Close a div popup after clicking outside it

Remember that jQuery library must be included.

Use following js code

jQuery(document).mouseup(function (event){
    var divcontainer = jQuery(".forclose" ); // Object of DIV
    if (divcontainer.has(event.target).length === 0){
        divcontainer.hide();
    }
});