Chris@0: /** Chris@0: * Implements hook_ranking(). Chris@0: */ Chris@0: function {{ machine_name }}_ranking() { Chris@0: // If voting is disabled, we can avoid returning the array, no hard feelings. Chris@0: if (variable_get('vote_node_enabled', TRUE)) { Chris@0: return array( Chris@0: 'vote_average' => array( Chris@0: 'title' => t('Average vote'), Chris@0: // Note that we use i.sid, the search index's search item id, rather than Chris@0: // n.nid. Chris@0: 'join' => array( Chris@0: 'type' => 'LEFT', Chris@0: 'table' => 'vote_node_data', Chris@0: 'alias' => 'vote_node_data', Chris@0: 'on' => 'vote_node_data.nid = i.sid', Chris@0: ), Chris@0: // The highest possible score should be 1, and the lowest possible score, Chris@0: // always 0, should be 0. Chris@0: 'score' => 'vote_node_data.average / CAST(%f AS DECIMAL)', Chris@0: // Pass in the highest possible voting score as a decimal argument. Chris@0: 'arguments' => array(variable_get('vote_score_max', 5)), Chris@0: ), Chris@0: ); Chris@0: } Chris@0: }