1

My client wants to have a different set of tabs for products belonging to category B. I added code below to Custom Layout settings.

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

It works so I can change the position of the tabs and put them above the add to cart blocks. But no matter what I do to local.xml the tabs stay the same for all products.

Here is what I have tried: in local.xml I added this -

<catalog_product_view>
    <reference name="product.info.additional">
        <block type="catalog/product_view_tabs" name="product.info.btabs" as="b_tabs">
            <action method="setTemplate">
                <template>catalog/product/view/tabs.phtml</template>
            </action>
            <action method="addTab" translate="title" module="catalog">
                <alias>description_tabbed</alias>
                <title>Details</title>
                <block>catalog/product_view_description</block>
                <template>catalog/product/view/description.phtml</template>
            </action>
            <action method="addTab" translate="title" module="catalog">
                <alias>additional_tabbed</alias>
                <title>Description</title>
                <block>catalog/product_view_attributes</block>
                <template>catalog/product/view/attributes.phtml</template>
            </action>
        </block>
    </reference>
    <reference name="product.info.additional">
        <action method="unsetChild">
            <name>product_tag_list</name>
        </action>
        <block type="catalog/product_view_tabs" name="product.info.tabs" as="info_tabs">
            <action method="setTemplate">
                <template>catalog/product/view/tabs.phtml</template>
            </action>
            <action method="addTab" translate="title" module="catalog">
                <alias>description_tabbed</alias>
                <title>Description</title>
                <block>catalog/product_view_description</block>
                <template>catalog/product/view/description.phtml</template>
            </action>
            <action method="addTab" translate="title" module="catalog">
                <alias>additional_tabbed</alias>
                <title>Additional</title>
                <block>catalog/product_view_attributes</block>
                <template>catalog/product/view/attributes.phtml</template>
            </action>
        </block>
    </reference>
</catalog_product_view>

in view-wfc.html I added this -

<?php echo $this->getChildHtml( 'b_tabs' ); ?>

Basically I want products in Category B to have tabs labeled "Details" and "Description" and to be in that order. In products belong to any category besides category B I want their tabs labeled "Description" and "Additional" and to be in that order.

Can anyone point me in the right direction?

1 Answer 1

0

On product pages, if you visit them via a category, the product will have an active category. With that you should be able to make an if/else for the tabs.

$category = Mage::registry('current_category');
if (!is_null($category)) {
   if ($category->getId() == X) { // id of category B
      echo $this->getChildHtml( 'b_tabs' );
   } else {
      echo $this->getChildHtml( 'info_tabs' );
   }
}
2
  • That does help with the conditional part. But the tabs are still the same. It doesn't matter if I call 'b_tabs' or 'info_tabs' I only get 'info_tabs' set. Can you please checkout the xml? Nov 11, 2014 at 16:41
  • It might be because the name is the same. Instead of using as please try and change the name to b_tabs and info_tabs
    – Sander Mangel
    Nov 12, 2014 at 6:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.