Search code examples
magentomagento-1.8magento-layout-xml

Magento Layout xml usage of <category_[id]>


I am attempting to replace the block that shows the image in the product view. I'm doing so programmatically with layout.xml. I've got it to work for all the products but I want to do it for only one category. My layout.xml is below; it is called from my config.xml in my module.

<?xml version="1.0"?>
<layout>

        <catalog_product_view>
           <!--here is where I had <CATEGORY_35> but it doesn't work-->
                    <reference name="head">
                                <action method="addJs"><script>chrysalis_monomer/chrysalis.js</script></action>
                    </reference>

                    <reference name="product.info.media">
                        <action method="setTemplate">
                            <template>catalog/product/view/chrysalis.phtml</template>
                        </action>
                    </reference>

           <!--/CATEGORY_35-->
        </catalog_product_view>

</layout>

where or how should I use a category handle to narrow this down to only products in a specific category? what about for only specific products? can I use a handle?


Solution

  • Category handles are not available on product view page. You can use product handle <PRODUCT_id> instead to target specific products. Also you can't put one handle inside another.

    <?xml version="1.0"?>
    <layout>
      <PRODUCT_123>
            <reference name="head">
                  <action method="addJs"><script>chrysalis_monomer/chrysalis.js</script></action>
            </reference>
    
            ...
    
      </PRODUCT_123>        
    </layout>