I used this documentation to create my reviews: http://drupal.org/node/457886
Furthermore I use Fivestar 6.x-1.19 and Contemplate 6.x-1.1 (all the latest edition right now).
The problem is that the average result for the node is not displaying, instead it displays the result of the latest review.
So if I have three reviews then the code below doesn't produce stars for the average, but rather the latest of these three reviews.
I've used contemplate to create the template for the main node (ie the product). In that template I've used the following code:
$stability_rating = votingapi_select_results(array('content_id' => $node->nid, 'tag' =>'stability', 'function' => 'average'));
$control_panel_rating = votingapi_select_results(array('content_id' => $node->nid, 'tag' =>'control_panel', 'function' => 'average'));
Then I use this to display it:
print theme('fivestar_static', $stability_rating[0]['value'], '5');
print theme('fivestar_static', $control_panel_rating[0]['value'], '5');
Five stars are max for my system.
Have you guys got any idea why this doesn't produce the average but the result of the latest review, please?
Comments
Comment #1
deanloh commentedHello MatteNoob
Did you cast the votes as different users? If you use the same login to cast vote, the system will always take account the latest ratings. This is logical so that users will not abuse the system by casting 100 votes and makes it look so popular.
Comment #2
MatteNoob commentedHi and thank you for your insights.
-----------------------------------------
EDIT: I solved this by using rules. I now create a new user called anonymous[node id] and assign that user to the author field when the review is published. I give these users the role of dummy. Not a good solution, but it solves it.
-----------------------------------------
Even when the users are anonymous? You see, this site gets its reviews from unauthenticated users. Then the review node is set to unpublished as default. Using rules the admins gets an email about a new review and publishes it.
In the database (table votingapi_cache) I see that the average from these unauthenticated users are stored as the latest review. Here is a short outtake on a node that has 3 reviews.
So I guess I need to do something to make the reviews from anonymous users stored as separate ones.
Is it possible to do something to make anonymous reviews count as separate ones? Please point me in the right direction.
An idea: Maybe I should use rules to set the field of the node author upon submission? (Like anonymous[nid]) Will this affect the voteapi_cache table?
Comment #3
clemens.tolboomI added a warning message into the documentation for multiaxis http://drupal.org/node/457886
I need reviews in time by the same user. Ie Review a Restaurant each month.
Casting votes through a Review nodes in time is possible through the votingapi (just don't delete old votes) but for FiveStart it is not possible to register a Review nid as the voting source.
My guess now is votingAPI must extend votingapi_vote table with a voting_source column.
What do your think?
[edit]
On second thought ... I think fivestar is in err by deleting casting votes from a 'review node' with a fivestar and noderef CCK field.
Comment #4
clemens.tolboomI think this is fixed with #561622: Allow multiple votes per user per target
Comment #5
that0n3guy commentedI tested that patch and it still doesn't work. This issue is still active.
Here is my setup:
- fivestar 1.19
- votingapi 2.3
I have multiple fivestar cck fields on the same node type with the "tag" set differently for each field. When going through this process:
- Create a relationship "node: voting results"
- Value type = percent
- vote tag = [set to one of my tags used in the cck fields]
- Aggregation function = average vote
... I get a value of the last review. NOT the average.
I tested this with the patch above and with 6.x-2.x-dev... no luck for any of them.
Comment #6
that0n3guy commentedok, retested... this is an issue with posting with the same use. I had to remove all reviews and redo them with the user (not just change the node author) to get this to work. I did my last ditch effort test after posting the above comment.
Comment #7
legolasboDrupal 6 is no longer supported. Closing old issues to clean up the issue queue.
Please reopen and update this issue if this is still an issue in the D7 or D8 version.