Mercurial > hg > cmmr2012-drupal-site
view vendor/chi-teck/drupal-code-generator/templates/d7/hook/ranking.twig @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | c75dbcec494b |
children |
line wrap: on
line source
/** * Implements hook_ranking(). */ function {{ machine_name }}_ranking() { // If voting is disabled, we can avoid returning the array, no hard feelings. if (variable_get('vote_node_enabled', TRUE)) { return array( 'vote_average' => array( 'title' => t('Average vote'), // Note that we use i.sid, the search index's search item id, rather than // n.nid. 'join' => array( 'type' => 'LEFT', 'table' => 'vote_node_data', 'alias' => 'vote_node_data', 'on' => 'vote_node_data.nid = i.sid', ), // The highest possible score should be 1, and the lowest possible score, // always 0, should be 0. 'score' => 'vote_node_data.average / CAST(%f AS DECIMAL)', // Pass in the highest possible voting score as a decimal argument. 'arguments' => array(variable_get('vote_score_max', 5)), ), ); } }