On a single entry page I'm displaying that entry's ratings using {exp:rating:entries}
. Within each rating returned, I'd like to display the average of some/all of the different ratings fields for that rating.
So I need something like {overall_avg}
but it's an average of the fields in that single rating rather then an average of all ratings for that entry.
I don't see any combination of tags that can make this happen. Any creative ways to achieve this?
Here some template code. Inside my channel:entries tag on a single entry page I have this embed code:
{embed="vendor/.ratings" entry-id="{entry_id}" vendor-type="{categories show_group="10" limit="1"}{category_url_title}{/categories}"}
And then the embed template looks like this:
{exp:rating:entries precision="2" orderby="rating_date" sort="desc" img_height="14" img_width="14" collection="directory" entry_id="{embed:entry-id}" limit="200"}
{if count == 1}
<article class="listing-reviews" id="listing-reviews">
<h3 class="centered"><em>{total_rating_count} review{if total_rating_count !="1"}s{/if}</em> for {title} <a class="btn directory write-edit" href="#listing-write-review">Write a review</a></h3>
{/if}
<section class="box review" id="review-{rating_id}">
<header>
{if photo}
{exp:ce_img:single class="pic" src="{photo_url}" max="45" crop="yes" alt="{name}"}
{if:else}
{exp:ce_img:single class="pic" src="/i/default-avatar.png" max="45" crop="yes" alt="{name}"}
{/if}
<h5>{name}</h5>
<h6>{who} • {rating_date format="%F %d, %Y"}</h6>
<div class="stars">
{stars}{rating}{/stars}
</div>
</header>
<div class="review-text">
<div class="restrict-height">
{review}
<div class="overflow"><a href="#">Read more…</a></div>
</div>
<p class="small light">Wedding Date: {wedding}</p>
</div>
<ul class="ratings">
<li>
<label>{{embed:vendor-type}_1label}</label>
{if rating1 !="" && rating1 !="0"}
<div class="stars">
{stars}{rating1}{/stars}
</div>
<span class="total">{rating1}</span>
{if:else}
<div class="stars">
<img src="/i/star-0.png" width="14" height="14" class="rating_star" />
<img src="/i/star-0.png" width="14" height="14" class="rating_star" />
<img src="/i/star-0.png" width="14" height="14" class="rating_star" />
<img src="/i/star-0.png" width="14" height="14" class="rating_star" />
<img src="/i/star-0.png" width="14" height="14" class="rating_star" />
</div>
<span class="total">N/A</span>
{/if}
</li>
<li>
<label>{{embed:vendor-type}_2label}</label>
{if rating2 !="" && rating2 !="0"}
<div class="stars">
{stars}{rating2}{/stars}
</div>
<span class="total">{rating2}</span>
{if:else}
<div class="stars">
<img src="/i/star-0.png" width="14" height="14" class="rating_star" />
<img src="/i/star-0.png" width="14" height="14" class="rating_star" />
<img src="/i/star-0.png" width="14" height="14" class="rating_star" />
<img src="/i/star-0.png" width="14" height="14" class="rating_star" />
<img src="/i/star-0.png" width="14" height="14" class="rating_star" />
</div>
<span class="total">N/A</span>
{/if}
</li>
<li>
<label>{{embed:vendor-type}_3label}</label>
{if rating3 !="" && rating3 !="0"}
<div class="stars">
{stars}{rating3}{/stars}
</div>
<span class="total">{rating3}</span>
{if:else}
<div class="stars">
<img src="/i/star-0.png" width="14" height="14" class="rating_star" />
<img src="/i/star-0.png" width="14" height="14" class="rating_star" />
<img src="/i/star-0.png" width="14" height="14" class="rating_star" />
<img src="/i/star-0.png" width="14" height="14" class="rating_star" />
<img src="/i/star-0.png" width="14" height="14" class="rating_star" />
</div>
<span class="total">N/A</span>
{/if}
</li>
<li>
<label>{{embed:vendor-type}_4label}</label>
{if rating4 !="" && rating4 !="0"}
<div class="stars">
{stars}{rating4}{/stars}
</div>
<span class="total">{rating4}</span>
{if:else}
<div class="stars">
<img src="/i/star-0.png" width="14" height="14" class="rating_star" />
<img src="/i/star-0.png" width="14" height="14" class="rating_star" />
<img src="/i/star-0.png" width="14" height="14" class="rating_star" />
<img src="/i/star-0.png" width="14" height="14" class="rating_star" />
<img src="/i/star-0.png" width="14" height="14" class="rating_star" />
</div>
<span class="total">N/A</span>
{/if}
</li>
</ul>
<footer>
{exp:rating:rating_vote_stats rating_id="{rating_id}"}
{if not_already_voted}<span class="helpful"><strong>Was this review helpful?</strong><a href="/vendor/rating-vote/{rating_id}/up/">Yes</a> | <a href="/vendor/rating-vote/{rating_id}/down/">No</a></span>{/if}
{if already_voted}<span class="helpful"><strong>Was this review helpful?</strong>Thanks for your vote</span>{/if}
<a class="permalink" href="#review-{rating_id}">#</a>
<a class="report" href="/contact">Problem with this review?</a>
{if total > 0}<span class="light people-like">{up_votes}/{total} people liked this review</span>{/if}
{/exp:rating:rating_vote_stats}
</footer>
</section>
{if count == total_rating_count}
</article>
{/if}
{/exp:rating:entries}
I would like to replace the line {stars}{rating}{/stars}
with stars for the average of the other 4 fields (rating1, rating2, rating3, rating4).
If I use the rating:stats, I can only specify an entry_id, which means I can get the average rating for the entry. I don't want that. I want the average rating of all rating fields for single rating. Since I cannot specify a rating_entry_id to the stats tag I cannot get an average for a single rating.
I hope that clarifies the question.
EE 2.7.2 Rating 3.2.3