Reputation: 11
In our Magento store we offer two kinds of products, each with their own root categories. I want to add CMS Static Blocks as custom tabs on product detail pages that are dependent on which category the product is under.
I know how to create tabs in the view.phtml
template, but how can I make it so that:
I think it is possible with XML layout updates to remove and append tabs, but how do I append the blocks to the layout?
Upvotes: 1
Views: 1841
Reputation: 1621
If I am understanding your question correctly, you want to add a custom tab on the product detail page when viewing the product under your two special categories (category1 and category2).
The tabs on the product detail page are of type catalog/product_view_tabs
which normally maps to the class Mage_Catalog_Block_Product_View_Tabs
. This block does provide a way to add new tabs through its addTab()
method, but it seems that this method assumes a template will be used, which unfortunately prevents using a CMS Static Block with this method.
If you are able to put your content from the two static blocks into two template files instead, you could do this using layout XML updates on the categories themselves. I will outline the process you would use in this scenario:
<reference name="content">
<reference name="product.info.tabs">
<action method="addTab" translate="title">
<alias>block1</alias>
<title>Block 1</title>
<block>core/template</block>
<template>catalog/product/view/block1.phtml</template>
</action>
</reference>
</reference>
It should look something like this:
Then just repeat the same steps for category2. The key to this solution working is to get your two template files block1.phtml
and block2.phtml
into the path: app/design/frontend/base/default/template/catalog/product/view/
.
Upvotes: 1