node_ranking()
Implements hook_ranking().
File
- core/modules/node/node.module, line 645
- The core module that allows content to be submitted to the site.
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 updated date, but only if it the scale values have // been calculated in node_cron(). if ($node_min_max = \Drupal::state()->get('node.min_max_update_time')) { $ranking['recent'] = array( 'title' => t('Recently created'), // Exponential decay with half life of 14% of the age range of nodes. 'score' => 'EXP(-5 * (1 - (n.created - :node_oldest) / :node_range))', 'arguments' => array( ':node_oldest' => $node_min_max['min_created'], ':node_range' => max($node_min_max['max_created'] - $node_min_max['min_created'], 1), ), ); } return $ranking; }
Please login to continue.