Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d7 / hook / ranking.twig
1 /**
2  * Implements hook_ranking().
3  */
4 function {{ machine_name }}_ranking() {
5   // If voting is disabled, we can avoid returning the array, no hard feelings.
6   if (variable_get('vote_node_enabled', TRUE)) {
7     return array(
8       'vote_average' => array(
9         'title' => t('Average vote'),
10         // Note that we use i.sid, the search index's search item id, rather than
11         // n.nid.
12         'join' => array(
13           'type' => 'LEFT',
14           'table' => 'vote_node_data',
15           'alias' => 'vote_node_data',
16           'on' => 'vote_node_data.nid = i.sid',
17         ),
18         // The highest possible score should be 1, and the lowest possible score,
19         // always 0, should be 0.
20         'score' => 'vote_node_data.average / CAST(%f AS DECIMAL)',
21         // Pass in the highest possible voting score as a decimal argument.
22         'arguments' => array(variable_get('vote_score_max', 5)),
23       ),
24     );
25   }
26 }