How to add hReview Aggregate formatting to JReviews

Recently I had a site that does not have that many quality editor reviews making the user reviews more helpful.  On this site I used the hReview-aggregate standard.

Steven Johnson
by | Posted: March 9, 2010 | Updated: April 1, 2014
Blog Post Image

Since I had seen several others looking for a write up I thought I would put this together to help others.

The hReview-aggregate formats the User ratng average and shows the review count, which is great for sites that have an active user review community.

What the User Sees:

Product Name Average User Ratings:
8.7 out of 10, based on 4 User Reviews

What the html looks like:

<div class="hreview-aggregate">
      <div class="item"><h4><span class="fn">Product Name</span> Average User Ratings:<br />
           <span class="rating"><span class="average">8.7</span> out of <span class="best">10</span>. Based on <span class="count">4</span></span> User Reviews.</h4>
       </div>
</div>   

JReviews Template Variables:

Product Name: you could use the listing title or a custom variables if they exist
Average User Rating: <?php echo $Rating->round($listing['Review']['user_rating'],$this->Config->rating_scale);?>
Best Score: Not Sure about this, right now I just used the number 10. (since I was on a 10 point scale)
User Review Count: <span class="count"><?php echo $listing['Review']['review_count'];?>

Here are some more jReviews Template Variables that may help

Adding the code to your JReviews template:

I added this code in the User summary box on the detail.thtml page.

See the code in action here: Fellowes DS 12CS Paper Shredder Review

The JReviews code added to the template, (note I used two custom fields to create the product name, you may not have to do this)

        <?php if($this->name != 'listings'): // Dont show unless in content page ?>
            <div class="roundedPanel jr_review" id="jr_reviewUserSummary">
                <div class="box_upperOuter">
                    <div class="box_upperInner">
                        <?php if($listing['Review']['user_rating_count']>0 && $listing['Criteria']['state'] == 1): ?>
                        <div class="hreview-aggregate">
                            <div class="item">
                            <h4 class="jr_reviewTitle"><span class="fn"><?php echo $CustomFields->field('jr_manufacturer',$listing,false,false); ?> <?php echo $CustomFields->field('jr_model',$listing,false,false); ?></span> Average User Ratings:</h4>
                            <h4 class="jr_reviewTitle"><span class="rating"><span class="average"><?php echo $Rating->round($listing['Review']['user_rating'],$this->Config->rating_scale);?></span> out of <span class="best">10</span>. Based on <span class="count"><?php echo $listing['Review']['review_count'];?></span></span> User Reviews.</h4>
                            </div>
                        </div>   
                        <?php endif;?>

Note: Since I use a 10 point scale I needed to include the span class of best so that the user review can be adjusted to a 5 point scale

hReview and Google Rich Snippet Resources

Hope this helps!

Follow Online Backup Search at Twitter Online Backup Search Feed Online Backup Search on FacebookOnline Backup Search on YoutubeIntown Web Design on Google+ Page