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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 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.