10

I have a content type "review" with a node reference to "product". I want to be able to have users rate the product while writing a detailed review. I added a Fivestar "rating" field in "review" and selected as "voting targed" the "node reference field". Users can enter the review and rate it at the same time. I created a view to show all the reviews for a product and it pulls the ratings nicely from the "rating" field.

However I can't get a view configured correctly to show an average rating for a product. I setup a relation with "Content: Vote results", left the "required" box unchecked, "value type" = percent, "vote tag" = "vote", "aggregation function" = "average vote". All the vote results fields come up empty.

What am I doing wrong?

thank you

2 Answers 2

6

You first need to go to path admin/structure/types/manage/product/fivestar and click the Enable Fivestar rating for the "vote" tag. For Full node display I choose Static display above node body because the voting widget will be on the Review form.

At admin/structure/types/manage/review/fields create a Node reference called Reference with a machine name field_review_reference. Add a field for Fivestar voting. Set the Voting target to Node Reference: field_review_reference. Under Reference Field Settings check the Product content type. At admin/structure/types/manage/review/fivestar the widget should NOT be enabled.

(edit: paragraph removed per suggestion of ericduran)

Now you can create another View with field to make a list of products that show fields from the product such as title, price, and image. Add the relationship Content: Vote results. Set Value type as percent, Vote tag as vote and Aggregations function as Average vote. Add the field Vote results: Value, set Relationship to Vote results, set Appearance to Fivestar Stars (display only).

That should be it.

5
  • thanks so much. Not enabling the Fivestar on the product type was the main problem. I tried to follow the EVA instructions including the patch but ran into a "out of memory error". Do you know of any EVA documentation or screencasts? Thanks again!
    – uwe
    Jun 20, 2011 at 19:34
  • @uwe999 You can try creating a variable to be printed in the node.tpl.php file using template_preprocess_node and some code like this ` if ($vars['type'] == 'annotation') { $vars['photos'] = views_embed_view('business_photos'); }`
    – Adam S
    Jun 20, 2011 at 19:54
  • 1
    I don't see why he needs to use Eva, or even views for that matter. I think that part should be remove from the answer since this one is accepted and just leave the other part of the answer intact. Eva is just going to confused people.
    – ericduran
    Jun 20, 2011 at 20:44
  • @ericduran I didn't know what step he was hung up so I just went through them all.
    – Adam S
    Jun 20, 2011 at 20:53
  • thats fine. Thanks for editing the answer. It'll save on suport request on the project page. + 1
    – ericduran
    Jun 20, 2011 at 22:02
3

In Drupal 7, there really is no reason to use a different content type for reviews. Unless you really want too.

In drupal 7 comments are now field-able which will allow your comments to use the fivestar rating field. Also when you use the fivestar field in a comment, there is now an option to use the "Parent Node" as the target which is exactly what you want.

After you have your comment set up to use the Parent Node as the target you still need to enable rating on the Product. The reason for this is that the vote will not be cast is the Tag being voted on isn't enabled.

Also makes sure you're using the latest -dev version. Fivestar doesn't currently have any release out yet. But it will really soon and the latest -dev version is pretty stable.

4
  • What are some of the reasons of using comments over node references? Are there any benefits to use a node reference? Is it possible to make a construction that show a Product, a node reference Review and comments on a Review.
    – Adam S
    Jun 20, 2011 at 16:41
  • thanks for the answer. I actually started modifying the "comments" to be used as reviews. Then I realized that I still want regular comments on the product and I would like to have regular comments for the reviews.
    – uwe
    Jun 20, 2011 at 18:11
  • 1
    With the drupal 7 version of fivestar you can pretty much make any entity have stars and also make any entity allow votes, so there is no need to make everything a node just because of that. If a review is a completely different thing then comments it makes perfect sense. If not is just better to use comments.
    – ericduran
    Jun 20, 2011 at 20:43
  • 1
    @adam s. Yes you can have a product and have rating from a review and/or comments. As long as they all use the same tag you can pretty much make any entity vote agains any other entity.
    – ericduran
    Jun 20, 2011 at 20:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.