【问题标题】:How to sort a view using Drupal Fivestar average ratings?如何使用 Drupal Fivestar 平均评级对视图进行排序?
【发布时间】:2009-09-13 02:52:06
【问题描述】:

我正在使用 Drupal 6.13、Views 6.x-2.6、Voting API 6.x-2.3、Fivestar 6.x-1.18。

我有一个内容类型,其字段类型为 Fivestar Rating。我有一个观点,我的意图是列出所有具有这种内容类型的节点,按总体平均评级降序排列。该视图正在显示正确的信息(具有投票能力的用户投票和总体平均投票)。但我这辈子都无法正确排序。

在视图中,我与“节点:投票结果”有关系,值类型=“百分比”,投票标签=“正常”,聚合函数:“平均”。

我已经尝试了很多东西,但我期望的工作是添加一个带有“(投票结果)投票结果:值”和降序的“排序标准”。当我这样做时,如果我查看 sql 查询并看到“ORDER BY node_title ASC”,这显然是不正确的。我希望看到“ORDER BYvotingapi_cache_node_percent_vote_average_value DESC”。任何指针将不胜感激。

在这里查询:

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

【问题讨论】:

    标签: drupal drupal-views drupal-fivestar


    【解决方案1】:

    这很奇怪; VotingAPI 中包含的“top_content”视图包括一个“五星”显示,可以准确设置您所描述的关系。它是否有效,或者它是否显示了您遇到的问题?

    【讨论】:

    • 我不知道有这样的东西存在......我会检查一下。
    【解决方案2】:

    啊,我想通了。我使用的是表格样式,并且在节点标题上设置了默认排序,导致所有排序标准都被忽略。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-14
      • 1970-01-01
      • 2011-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多