I want to hide the product-collateral tab present in product details page when no value is entered for that attribute. am stuck here.

The tab coding in view.phtml is this:

<div class="product-collateral toggle-content tabs">
    <?php if ($detailedInfoGroup = $this->getChildGroup('detailed_info', 'getChildHtml')):?>
        <dl id="collateral-tabs" class="collateral-tabs">
            <?php foreach ($detailedInfoGroup as $alias => $html):?>
                <dt class="tab"><span><?php echo $this->escapeHtml($this->getChildData($alias, 'title')) ?></span></dt>
                <dd class="tab-container">
                    <div class="tab-content"><?php echo $html ?></div>
            <?php endforeach;?>
    <?php endif; ?>

In catalog.xml it is called like:

<block type="catalog/product_view_description" name="product.description" as="description" template="catalog/product/view/description.phtml">  
    <action method="addToParentGroup"><group>detailed_info</group></action>
    <action method="setTitle" translate="value"><value>Description</value></action>

The description.phtml is this:

<?php $_description = Mage::registry('current_product')->getDescription(); ?>
<?php if ($_description): ?>
    <div class="std">
        <?php echo $this->helper('catalog/output')->productAttribute(Mage::registry('current_product'), $_description, 'description') ?>
<?php endif; ?>

Please guide me how to hide the tab when no value is entered in description attribute field.I dont exactly know the jquery responsible for this.


You can add a condition here. This will skip the tab from rendering


<dl id="collateral-tabs" class="collateral-tabs">
    <?php foreach ($detailedInfoGroup as $alias => $html):?>
        if($alias=="description") continue; 
        // if(trim($html)=="") continue;
        <dt class="tab"><span><?php echo $this->escapeHtml($this->getChildData($alias, 'title')) ?></span></dt>



You can compare name of any tab here if($alias=="NAME_OF_TAB")

  • when I included this code <?php //ADD YOUR CONDITION HERE if($alias=="description") continue; ?> it is hiding the tab even when there is value. – Ramya May 27 '16 at 6:53
  • you want to hide tab, if whole description content OR HTML is empty, right ? – Anil Suthar May 27 '16 at 6:55
  • yes. When No value is entered in that attribute field it should be hidden. – Ramya May 27 '16 at 6:56
  • 1
    use if(trim($html)=="") continue; – Anil Suthar May 27 '16 at 6:58
  • 1
    Why this ans is accepted? Its not working at all. – Indian Sep 20 '17 at 11:31

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.