0
votes

I have successfully added a tab to my view.phtml page located at app/design/frontend/enterprise/aps/template/catalog/product.

I tried an if statement to hide it if the Specifications field is empty, i.e. no content. The issue is, it doesn't work. It still shows the tab even if there is no content.

My code is below at the end of post.

2 Questions:

  1. Am I taking the correct approach? Basically, I am making a tab to have an Expert Review tab. I originally was going to use a cms block, but figured purposing the Specifications field was easier, for one, but also I could ignore the tab if no content

  2. Can you please help ? :)

Thanks so much and here is my code and I attached a screenshot of the empty tabs.

<div class="wa-product-details-tab product-description">
            <div class="wa-product-details-tab-heading product-desc-tab">
                <div rel=".wa-product-tab-details-item-1" class="wa-product-heading-item wa-product-heading-item-1 wa-product-heading-item-active">
                    <span>Description</span>
                </div>
                <div rel=".wa-product-tab-details-item-2" class="wa-product-heading-item wa-product-heading-item-2">
                    <span>Specs</span>
                </div>
                <div rel=".wa-product-tab-details-item-3" id="review-form" class="wa-product-heading-item wa-product-heading-item-3">
                <?php
                    $summaryData = Mage::getModel('review/review_summary')
                                    ->setStoreId(Mage::app()->getStore()->getId())
                                    ->load($_product->getId());
                ?>
                <span >Reviews &nbsp;(<?php echo $summaryData->getReviewsCount();?>)</span>

                </div>
                <div rel=".wa-product-tab-details-item-4" class="wa-product-heading-item wa-product-heading-item-4">
                    <span>APS Advisor Review</span>
                </div>
            </div>

            <div class="wa-product-tab-details product-desc">
                <div style="display: block;" class="wa-product-tab-details-item wa-product-tab-details-item-1">
                    <?php  echo $_product->getDescription();  ?>
                </div>

                <div style="display: none;" class="wa-product-tab-details-item wa-product-tab-details-item-2">

                    <p> <?php echo $this->getChildHtml('additional')?></p>

                </div>
                <div style="display: none;" class="wa-product-tab-details-item wa-product-tab-details-item-3">

                    <p>
                    <?php echo $this->getChildHtml('review_form') ?>
                    <?php echo $this->getChildHtml('product_additional_data_review') ?>

                    </p>

                </div>
                <div style="display: none;" class="wa-product-tab-details-item wa-product-tab-details-item-4">
                    <?php  if ($_product->getSpecifications()); ?>
                </div>
            </div>

MIssing tab image

1
Have you all changed the default tab ? The default tab doesn't render this way. it needs to be done with xml layout to achieve for what you are asking for. else we need to do it on interface level.Suman KC
Not sure what you mean by that exactly. This is on a custom theme I didn't design. I did read about doing this via the local.xml file but didn't have any success there. I can dig deeper but I was successful using the code above getting the 4th tab, APS Advisor Review to dislay and populate with the Specifications field, I just haven't been able to get it to hide when empty. Any insight is appreciated. Thanks.kory mitchell

1 Answers

0
votes

I am not sure if I understood your issue correctly. I am assuming that you want to hide the "APS Advisor Review" tab if there is no content in it.

For this you can use an if condition to check if $_product->getSpecifications() has any content, and show the tab title only if there is any content like this

<?php if( !empty($_product->getSpecifications()) ){ ?> <!-- displays the tab title only if the product has any specifications -->
        <div rel=".wa-product-tab-details-item-4" class="wa-product-heading-item wa-product-heading-item-4">
            <span>APS Advisor Review</span>
        </div>
<php } ?>