3

Should be simple. I have a content type called Product. I have another content type called Review.

I want people to vote when they create the Review content type and have the vote count towards the Product. When I display the Product, I want the average of the votes to appear with the product. Problem: When I add the fivestar field to the Review content type I DO NOT see an option to set a target node.

Note: I am not using comments as reviews, I am using another content type.

I have tried to find a solution in other postings and I have no problem with a programmatic solution but I have not found anything clear.

1
  • Please specify the Drupal version you are using for clarity!
    – Alex Weber
    Commented Apr 15, 2012 at 4:02

2 Answers 2

2

The problem was that I had just switched the links between my Reviews -> Products to use entity relationships (instead of node links) and Fivestar does not support that.

A patch that seems to work was posted two days ago. As soon as I applied the patch, the "target node" field appeared. http://drupal.org/node/1488914

In addition, the product's Fivestar field had to be set to "rate while viewing" and the Review's Fivestar field had to be set to edit while eediting.

0

Since Fivestar uses Voting API to do the heavy lifting, you can use some of Voting API's hooks to intercept votes and do your magic there.

Alternatively, when you display the Product you can implement a preproces_node to fetch all reviews for that product and manually count the votes and calculate the average.

That said, I'd create some hidden fields in the product (#access false ftw) and manually update them with every vote using the aforementioned hooks.

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.