Jump to content

Average Rating from Comments Field


quickjeff
 Share

Recommended Posts

Hello,

here is example from one of my projects and don't know if that can help you.

comments-foto-2.png.ef4f2c222db68157819c5942fdd2ac55.png

That example show AVG of 4.6, and below is copy/paste how I get that.

I believe that only what you need is to set "use stars", and this call:

$page->comments->renderStars(true, array('schema'=>'microdata','partials'=>true));

Or more details, where I use that:

<?php if($page->comments->count):?>
<div class="star-rating">
   <div class="rating-counter">
	   <a href="#listing-reviews">
	   <?php echo $page->comments->renderStars(true, array('schema'=>'microdata','partials'=>true));?>
	   </a>
   </div>
</div>
<?php endif;?>

If that is interesting, here is and Comments configuration to use Font Awesome icons.

CommentStars::setDefault('star', '<i class="fa fa-star"></i>'); //<= star item using fontawesome icon

Regards.

  • Like 4
  • Thanks 2
Link to comment
Share on other sites

  • 6 months later...

Hello @OLSA Could you please explain where should I put the 

CommentStars::setDefault('star', '<i class="fa fa-star"></i>'); //<= star item using fontawesome icon

as this is my first time needing to replace the default stars with some FA icons and it would be a great addition to my learning curve ? I see the same info in the comments field details tab, however am not sure how to insert it properly to have the stars changed to else.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...