function comment_ranking

Same name in other branches
  1. 9 core/modules/comment/comment.module \comment_ranking()
  2. 8.9.x core/modules/comment/comment.module \comment_ranking()
  3. 10 core/modules/comment/comment.module \comment_ranking()
  4. 11.x core/modules/comment/comment.module \comment_ranking()

Implements hook_ranking().

File

modules/comment/comment.module, line 2690

Code

function comment_ranking() {
    return array(
        'comments' => array(
            'title' => t('Number of comments'),
            'join' => array(
                'type' => 'LEFT',
                'table' => 'node_comment_statistics',
                'alias' => 'node_comment_statistics',
                'on' => 'node_comment_statistics.nid = i.sid',
            ),
            // Inverse law that maps the highest reply count on the site to 1 and 0 to 0.
'score' => '2.0 - 2.0 / (1.0 + node_comment_statistics.comment_count * CAST(:scale AS DECIMAL))',
            'arguments' => array(
                ':scale' => variable_get('node_cron_comments_scale', 0),
            ),
        ),
    );
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.