Closed (fixed)
Project:
Fivestar
Version:
6.x-1.19
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
20 Dec 2009 at 05:04 UTC
Updated:
3 Feb 2017 at 13:24 UTC
Jump to comment: Most recent
I'm working on a multi-axis rating system and using views custom fields to do the averaging, but I am hoping for some code help to show the rating as something OTHER than stars.
My current averaging code:
$avg = round(($data->appearance+ $data->aroma + $data->flavor + $data->feel + $data->overall )/5);
print theme('fivestar_static', $avg, '5');
That shows the average rating as stars, but I am looking to show the rating 2 other ways:
1. overall percent, such as: "80"
2. # of stars numerically, such as: "4.75 / 5"
Any thoughts?
Comments
Comment #1
youkho commentedLooking for a solution for this too some have an idea?
Comment #2
madaxe commentedIn Drupal 6 I got my fivestar node vote to print out numerical display with the following code
This prints out the result with 1 decimal place. To have more decimal places then change the 1 in the last line to whatever number of decimal places you wish
e.g. print number_format($votesavg, 4, '.', ''); would give 4 decimal places.
Anybody feel free to improve this code. I'm not exactly Mr Sheen when it comes to code, I can at times be a bit more of a Charlie Sheen.
Comment #4
dbt102 commentedComment #5
dbt102 commentedDrupal 6 is now end of life, and is no longer supported. So Drupal 6 issues for Fivestar are being closed as "Closed (outdated)". However, we don't want users who are porting from Drupal 6 (or 7) to D8 to feel unwanted, so if you have any migration issues, please open them as Drupal 8 issues.