function node_ranking
Same name in other branches
- 9 core/modules/node/node.module \node_ranking()
- 8.9.x core/modules/node/node.module \node_ranking()
- 10 core/modules/node/node.module \node_ranking()
- 11.x core/modules/node/node.module \node_ranking()
Implements hook_ranking().
File
-
modules/
node/ node.module, line 1759
Code
function node_ranking() {
// Create the ranking array and add the basic ranking options.
$ranking = array(
'relevance' => array(
'title' => t('Keyword relevance'),
// Average relevance values hover around 0.15
'score' => 'i.relevance',
),
'sticky' => array(
'title' => t('Content is sticky at top of lists'),
// The sticky flag is either 0 or 1, which is automatically normalized.
'score' => 'n.sticky',
),
'promote' => array(
'title' => t('Content is promoted to the front page'),
// The promote flag is either 0 or 1, which is automatically normalized.
'score' => 'n.promote',
),
);
// Add relevance based on creation or changed date.
if ($node_cron_last = variable_get('node_cron_last', 0)) {
$ranking['recent'] = array(
'title' => t('Recently posted'),
// Exponential decay with half-life of 6 months, starting at last indexed node
'score' => 'POW(2.0, (GREATEST(n.created, n.changed) - :node_cron_last) * 6.43e-8)',
'arguments' => array(
':node_cron_last' => $node_cron_last,
),
);
}
return $ranking;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.