2

My magento-product doesn't have any product detail infos (attributes) at my backend. But I see the empty "Product Detail Tab" on detail page. See screenshot. How can I hide the Tabs in frontend. The Tabs are in my "catalog/product/view/tabs.phtml"

<?php foreach ($this->getTabs() as $_index => $_tab): ?>
<?php
if (($showDescription && $_tab['alias'] == 'description') || $_tab['alias'] != 'description') {
    if (($showDetails && $_tab['alias'] == 'additional') || $_tab['alias'] != 'additional') {
        if (($showDetailsTab && $_tab['alias'] == 'additional_tab') || $_tab['alias'] != 'additional_tab') {
            if ($tmpBlock = $this->getChildHtml($_tab['alias'])) {
                $_panes .= '<h2 class="acctab" id="acctab-' . $_tab['alias'] . '">' . $_tab['title'] . '</h2>';
                $_panes .= '<div class="panel">' . $tmpBlock . '</div>';
            }
        }
    }
}
?>

...

    <div id="product-tabs" class="gen-tabs gen-tabs-style1">

    <?php //IMPORTANT: id "product-tabs" is being used in: /catalog/product/view.phtml, /review/helper/summary*_nolinks.phtml   ?>
    <ul class="tabs clearer">
        <?php foreach ($this->getTabs() as $_index => $_tab): ?>
            <?php if (($showDescription && $_tab['alias'] == 'description') || $_tab['alias'] != 'description'): ?>
                <?php if (($showDetails && $_tab['alias'] == 'additional') || $_tab['alias'] != 'additional'): ?>
                <?php if (($showDetailsTab && $_tab['alias'] == 'additional_tab') || $_tab['alias'] != 'additional_tab'): ?>
                    <?php if ($this->getChildHtml($_tab['alias'])): ?>
                        <li id="tab-<?php echo $_tab['alias'] ?>"><a href="#"><?php echo $_tab['title'] ?></a></li>
                    <?php endif; ?>
                <?php endif; ?>  
            <?php endif; ?>
            <?php endif; ?>
        <?php endforeach; ?>
        <?php echo $_extraTabs; //Append extra tabs after regular tabs ?>
    </ul>
    <div class="tabs-panels"><?php echo $_panes, $_extraPanes; //Append extra panels to regular panels     ?></div>

</div>

show product details (attributes), but its empty?!

2 Answers 2

4

The code in tabs.phtml looks like this:

<ul class="product-tabs">
    <?php foreach ($this->getTabs() as $_index => $_tab): ?>
        <?php if($this->getChildHtml($_tab['alias'])): ?>
            <li id="product_tabs_<?php echo $_tab['alias'] ?>" class="<?php echo !$_index?' active first':(($_index==count($this->getTabs())-1)?' last':'')?>"><a href="#"><?php echo $_tab['title']?></a></li>
        <?php endif; ?>
    <?php endforeach; ?>
</ul>
<?php foreach ($this->getTabs() as $_index => $_tab): ?>
    <?php if($this->getChildHtml($_tab['alias'])): ?>
        <div class="product-tabs-content" id="product_tabs_<?php echo $_tab['alias'] ?>_contents"><?php echo $this->getChildHtml($_tab['alias']) ?></div>
    <?php endif; ?>
<?php endforeach; ?>

So if a tab content is empty then the tab is not shown.
Either you have a different code, or your tab content is not empty. It may contain something like <div></div> or something like that.
In this case you can change the if statement to remove your tags.
Maybe something like this:

<ul class="product-tabs">
    <?php foreach ($this->getTabs() as $_index => $_tab): ?>
        <?php if(trim(strip_tags($this->getChildHtml($_tab['alias'])))): ?>
            <li id="product_tabs_<?php echo $_tab['alias'] ?>" class="<?php echo !$_index?' active first':(($_index==count($this->getTabs())-1)?' last':'')?>"><a href="#"><?php echo $_tab['title']?></a></li>
        <?php endif; ?>
    <?php endforeach; ?>
</ul>
<?php foreach ($this->getTabs() as $_index => $_tab): ?>
    <?php if(trim(strip_tags($this->getChildHtml($_tab['alias'])))): ?>
        <div class="product-tabs-content" id="product_tabs_<?php echo $_tab['alias'] ?>_contents"><?php echo $this->getChildHtml($_tab['alias']) ?></div>
    <?php endif; ?>
<?php endforeach; ?>
1
  • I use the ultimo theme. my code looks a bit different?! see my question, I've edit it and post my code. Feb 14, 2014 at 10:31
0

You need to add trim(strip_tags() in both if condition under foreach loop.

Below code tested in ultimo theme.

change line no 11

if($tmpBlock = $this->getChildHtml($_tab['alias']))

to

if($tmpBlock = trim(strip_tags($this->getChildHtml($_tab['alias']))))

and line no 35

<?php if($this->getChildHtml($_tab['alias'])): ?>

to

 <?php if(trim(strip_tags($this->getChildHtml($_tab['alias'])))): ?>

Hope, it will be help.

4
  • change line 35 with <?php if(trim(strip_tags($this->getChildHtml($_tab['alias'])))): ?> Nov 30, 2016 at 9:14
  • I've tried this solution however it removes all of the styling and what not within the other tabs.. any ideas?
    – ne0nlight
    Jan 17, 2017 at 20:15
  • are you using ultimo theme? Jan 18, 2017 at 7:17
  • Yes I am, and it turns out if your tab content is empty, ultimo will automatically hide it, so I removed the text I was saving for if there was no details anyway, and it worked out. Thanks!
    – ne0nlight
    Jan 18, 2017 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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