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  

This is an old revision of the document!


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; ?>

add:

<?php else: ?>

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.




 

Magento 2 GitHub Repository

Magento Job Board - Some sort of tag line goes here

Latest Posts| View all Jobs