views:

1549

answers:

3

I am using Drupal 6.13, Views 6.x-2.6, Voting API 6.x-2.3, Fivestar 6.x-1.18.

I have a content type with field of type Fivestar Rating. I have a view where my intention is to list all of the nodes with this content type sorted in descending order by the overall average rating. The view is working in that it is showing the correct information (the user vote with ability to vote and the overall average vote). But I can't for the life of me get it to sort properly.

In the view, I have a relationship with "Node: Vote results", Value type = "Percent", Vote tag = "Normal", Aggregation function: "Average".

I've tried a bunch of things but what I expect to work is to add a "Sort criteria" with "(Vote results) Vote results: Value" and descending. When I do that if I look at the sql query and I see "ORDER BY node_title ASC" which is obviously not right. I would expect to see "ORDER BY votingapi_cache_node_percent_vote_average_value DESC". Any pointers would be most appreciated.

Query here:

SELECT node.nid AS nid,
   node.title AS node_title,
   profile_values_profile_full_name.value AS profile_values_profile_full_name_value,
   users.uid AS users_uid,
   votingapi_vote_node_percent_vote_curuser.value AS votingapi_vote_node_percent_vote_curuser_value,
   votingapi_cache_node_percent_vote_average.value AS votingapi_cache_node_percent_vote_average_value
 FROM node node 
 LEFT JOIN votingapi_cache votingapi_cache_node_percent_vote_average ON node.nid = votingapi_cache_node_percent_vote_average.content_id AND (votingapi_cache_node_percent_vote_average.content_type = 'node' AND votingapi_cache_node_percent_vote_average.value_type = 'percent' AND votingapi_cache_node_percent_vote_average.tag = 'vote' AND votingapi_cache_node_percent_vote_average.function = 'average')
 LEFT JOIN votingapi_vote votingapi_vote_node_percent_vote_curuser ON node.nid = votingapi_vote_node_percent_vote_curuser.content_id AND (votingapi_vote_node_percent_vote_curuser.content_type = 'node' AND votingapi_vote_node_percent_vote_curuser.value_type = 'percent' AND votingapi_vote_node_percent_vote_curuser.tag = 'vote' AND votingapi_vote_node_percent_vote_curuser.uid = '***CURRENT_USER***')
 LEFT JOIN node_revisions node_revisions ON node.vid = node_revisions.vid
 LEFT JOIN users users_node_revisions ON node_revisions.uid = users_node_revisions.uid
 INNER JOIN users users ON node.uid = users.uid
 LEFT JOIN profile_values profile_values_profile_full_name ON users.uid = profile_values_profile_full_name.uid AND profile_values_profile_full_name.fid = '5'
 WHERE (node.type in ('passion_talk')) AND (node.status <> 0)
   ORDER BY node_title ASC
+2  A: 

That's pretty bizarre; the 'top_content' view that's included with VotingAPI includes a 'Fivestar' display that sets up exactly the relationship you're describing. Does it work, or does it display the problem you're encountering?

Eaton
I was not aware such a thing existed...I'll check it out.
Alex Miller
+1  A: 

Ah, I figured it out. I was using Table style and there was a default sort set up on the node title that caused all sort criteria to be ignored.

Alex Miller
A: 

Ever got around fivestar and php 5.3 issue?

bankai