How to hide Review Tabs when no reviews present in Modern Theme

Last modified by rickahontas on Thu, June 24, 2010 17:07
Source|Old Revisions  

I wanted to hide my reviews tab from view on product pages lacking a product review. To do so, go into your:

app / design / frontend / (package name, usually default) / (your theme) / template / review / product /view / list.phtml

and find:

<?php if (count($_items)):?>

and comment it out and place this underneath it, like so:

<?php //if (count($_items)):?> <?php if (!empty($_items)):?>

Since the original list.phtml file had a simple <?php> if statement, we now need to give it an else statment so it knows what to do with itself after it can’t find reviews for the product.

At the bottom of list.phtml, before:

<?php endif; ?>


<?php else: ?>

Your last four/five lines of code should look like:

<?php echo $this→getChildHtml(’toolbar’) ?> </div> <?php else: ?> <?php endif;?> <?php echo $this→getChildHtml(’review_form’) ?>

Make sure you use a colon after else to tell the document to continue executing code, a semi colon completes a function.

Your tabs should be devoid of a Review Tab on all products missing a review, if all is done properly.