Wednesday, September 21, 2011

Add Fivestar ratings in comments and display average rating in node


I wanted to add Fivestar ratings in the comments section so people could give their opinions about my products and display the average rating in the product node. This was actually an easy task once I figured out how to do it, but the process is not straight forward. I thought other people would want to know how:

1. Install the Fivestar module and Vote API.

2. Go to admin/config/content/fivestar and create a new voting tag: rating.

3. Go to admin/structure/types and create or edit your content type.

4. In the Manage Fields tab, add a field to display the average rating: label "Average Rating", name "rating", type of data "Fivestar Rating", and form element "Stars (rated while viewing)". Save.

5. Select the Voting Tag: "rating" and Save field settings.

6. Leave the default settings but make sure the Voting Tag is "rating". Save field settings.

8. Go to the Manage Display tab, and click on the format configuration icon of the Average Rating Field. Disable check-box to Expose this Fivestar field for voting on the @type type. Click on Save.


9. Go to the Comment Fields tab and add an existing field: label "Your rating", field to share "Fivestar Rating: field_rating (Average Rating)" and form element "Stars (rated while editing)". Click on Save.


10. Change the Voting target to "Parent Node". Click on Save Settings.

11. You are done!



Special thanks to Eric Duran who initially explained this process: