Closed (outdated)
Project:
Rate
Version:
7.x-1.6
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
2 Nov 2010 at 21:20 UTC
Updated:
18 Sep 2025 at 12:04 UTC
Jump to comment: Most recent
I'm using rate with value type options in a view. I want to know how I can sort by the highest rated in each option. You can see this up at http://ideapals.org If you scroll down past the "under construction" graphic. Each option is an emotion like "Train Wreck", "Brilliant", etc. I need to be able to make a top list that shows the top ideas voted 'brilliant' etc. I used a node relationship, and I can get the votes to show up in views, the rating is working perfectly, but I need to know how to sort by the highest votes in a particular option? Ideas, advice, solutions? BTW, LOVE the module.
Comments
Comment #1
mauritsl commentedI was unsure if this is possible in views, but I got it working :)
Not many people seems to be doing this, as it results in a SQL error in views. I wrote a patch which fixes this bug, please refer to:
http://drupal.org/node/937998#comment-3658114
Apply that patch before we begin, you won't get it working otherwise.
The configuration is far from straightforward, but I'll explain. Start with a relationship to "Vote results" (you will find it under the category "Node"). The options you have to use here are different from the configuration as described in the readme file.
* Require this relationship: check this box
* Value type: other, fill in "option"
* Vote tag: same value as used in the rate widget configuration
* Aggregation function: Other, fill in "option-2", where 2 is the value of the option (visible in the rate widget configuration). You may use another value than 2 of course.
Now add a sort criteria on "Vote results: Value". Under "Relationship", select the relationship you just created. Ordering has to be descending.
Add a field with the type "Vote results: Value". Use the same relationship and choose the rate widget under "Appearance".
You have to create a display for each option. Only the value used for the aggregation function in the relationship has to be different, as that option determines what rate button the view is for.
And here is an export of my view:
Comment #3
N1L commentedYou are awesome mate! Thanks for that patch.
Comment #4
mrweiner commentedI've come across this exact same issue in D7, and need this functionality for my site. Does anybody know if this should have been fixed, or how to fix it? I looked at the patch linked in the first comment, but it doesn't look like it can be applied to the current version of Voting API.
Comment #5
mrweiner commentedSorry, wrong version selected. :(
Comment #6
mototribe commentedsee http://drupal.org/node/1066838
Comment #7
mrweiner commentedWell, if that is the way that it is supposed to work, then I'm changing this to a bug report. If I have an "options" widget setup, and everything configured as laid out in that thread and elsewhere, the sort does not work. Both ascending and descending show the results in the same order, and neither of them are remotely correct.
The options in my widget are "Helpful" and "Unhelpful". Before I stopped trying to figure this problem out, the view's sorts would show one node with a vote of "Helpful", one node with a vote of "Unhelpful", and then the rest in no reasonable order. I can provide an export of the view, or anything else that's required, if somebody tells me what they would need to help diagnose the problem.
Comment #8
mrweiner commentedOf course, I decide to try it one more time, and it works. Not sure what I was doing wrong before.
Comment #9
mrweiner commentedSorry to clog up the issue page, but this seems to not actually be working for me. It only appeared to be working momentarily. The random results, as described below, just happened to appear in the order which seemed to be correct. To give an example of the issues, my rate widget type is "options". The options of the widget are Helpful, with a value of 1, and Unhelpful, with a value of -1. With the relationship configured as it should be, and without an "aggregation function" (image 1):
In descending mode, they are shown in no particular order, with voted nodes first and non-voted nodes after.
In ascending mode, the results are reversed. Non-voted nodes are shown first, and then voted nodes are shown in the opposite order from before.
With the same relationship configuration, but with an aggregation function of "Total score" (image 2):
Both ascending and descending appear to sort by a completely random order. It doesn't seem to be sorted by anything related to the votes themselves or other aspects of the node.
If this is the intended functionality of the module, then I am rather baffled.
Comment #10
xandeadx commentedModule for 6.x branch allowing sort on average value Yes/No widget — http://drupal.org/sandbox/xandeadx/1790062
Comment #11
scoffield commentedDoes anybody have a solution to sort nodes by "options" with views in the version 1.4 of rate module.
I try to sort nodes by total sum of yes/no, but it s not working with drupal 7, votingapi and rate updated.
I did not see my options when i had a relationship in a view. I only saw "no filters" or "normal vote".
Or am i doing this false ? Did views and rate work on your website ?
Comment #12
ymakux commentedscoffield: same situation. In my case I need to display 5 most useful comments (yes/no widget).
Comment #13
ymakux commentedOk, got it (comments)
Comment #14
mrweiner commented@ymakux: Would you mind describing what you did to get it working?
Comment #15
pradyumnahpt commentedEven I too have a problem sorting the comments from views based on the number of votes, even after following steps mentioned in readme,and the patch in comment #1 cannot be applied for latest recommended release. I am using points value type.and the sort is not stable,It appears to sort correctly sometimes but the sort functionality is not working.Any one please guide to get it right..
Thankyou
Comment #16
ivnishDrupal 7 is EOL. Issue will be closed