我正在使用 Drupal 6,并且在我的节点上有多个标志,每个标志都有一个值,例如:有趣、无聊、聪明、有趣、辱骂等。 Views 目前能够按每个单独标志的标志计数对结果进行排序,但我需要按每个音符上所有标志的总组合标志数对我的节点进行排序。'rate' 模块非常接近于这样做,但我需要使用 flag 模块,以便我可以使用 flag solr 模块来允许按标志搜索。我真的不知道从哪里开始......关于我可以采取的方法的任何建议?
这是当前的视图查询;
SELECT node.nid AS nid,
flag_counts_node.count AS flag_counts_node_count,
flag_counts_node_1.count AS flag_counts_node_1_count,
flag_counts_node_2.count AS flag_counts_node_2_count,
flag_counts_node_3.count AS flag_counts_node_3_count,
flag_counts_node_4.count AS flag_counts_node_4_count FROM node node
LEFT JOIN flag_counts flag_counts_node ON node.nid = flag_counts_node.content_id AND flag_counts_node.fid = 7
LEFT JOIN flag_counts flag_counts_node_1 ON node.nid = flag_counts_node_1.content_id AND flag_counts_node_1.fid = 6
LEFT JOIN flag_counts flag_counts_node_2 ON node.nid = flag_counts_node_2.content_id AND flag_counts_node_2.fid = 4
LEFT JOIN flag_counts flag_counts_node_3 ON node.nid = flag_counts_node_3.content_id AND flag_counts_node_3.fid = 5
LEFT JOIN flag_counts flag_counts_node_4 ON node.nid = flag_counts_node_4.content_id AND flag_counts_node_4.fid = 3
WHERE (node.type in ('rpodcast', 'upodcast')) AND (node.status = 1) ORDER BY flag_counts_node_count ASC, flag_counts_node_1_count ASC, flag_counts_node_2_count ASC, flag_counts_node_3_count ASC, flag_counts_node_4_count ASC
到目前为止的模块代码;
<?php
function flagcountview_views_pre_execute(&$view){
if ($view->name == 'audio') {
$sql = $view->build_info['query'];
$flag_count = "flag_counts_node.count + flag_counts_node_1.count + flag_counts_node_2.count + flag_counts_node_3.count";
$sql .= "ORDER BY $flag_count DESC";
$view->build_info['query'] = $sql;
}
}