function comment_node_search_result
Same name in other branches
- 9 core/modules/comment/comment.module \comment_node_search_result()
- 8.9.x core/modules/comment/comment.module \comment_node_search_result()
- 10 core/modules/comment/comment.module \comment_node_search_result()
- 11.x core/modules/comment/comment.module \comment_node_search_result()
Implements hook_node_search_result().
Formats a comment count string and returns it, for display with search results.
File
-
modules/
comment/ comment.module, line 1393
Code
function comment_node_search_result($node) {
// Do not make a string if comments are hidden.
if (user_access('access comments') && $node->comment != COMMENT_NODE_HIDDEN) {
$comments = db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = :nid', array(
'nid' => $node->nid,
))
->fetchField();
// Do not make a string if comments are closed and there are currently
// zero comments.
if ($node->comment != COMMENT_NODE_CLOSED || $comments > 0) {
return array(
'comment' => format_plural($comments, '1 comment', '@count comments'),
);
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.