diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-04-26 14:26:46 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-04-26 14:26:46 +0000 |
commit | 96bfc650bc1f4430654575b8872e77c90bb8d50c (patch) | |
tree | 7b4bfa9e995d880eec5aebb693c26e96d7785de5 /modules/comment | |
parent | b6480251b89f75d4038f45a0c6f0e33833ec2307 (diff) | |
download | brdo-96bfc650bc1f4430654575b8872e77c90bb8d50c.tar.gz brdo-96bfc650bc1f4430654575b8872e77c90bb8d50c.tar.bz2 |
- Patch #537278 by jhodgdon, caelon, dtarc: search results show comment count for content types where comments are disabled.
Diffstat (limited to 'modules/comment')
-rw-r--r-- | modules/comment/comment.module | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/modules/comment/comment.module b/modules/comment/comment.module index fa1fe1cbf..4a466fa59 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -1294,13 +1294,20 @@ function comment_update_index() { /** * Implements hook_node_search_result(). + * + * Formats a comment count string and returns it, for display with search + * results. */ function comment_node_search_result($node) { + // Do not make a string if comments are hidden. if ($node->comment != COMMENT_NODE_HIDDEN) { $comments = db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = :nid', array('nid' => $node->nid))->fetchField(); - return format_plural($comments, '1 comment', '@count comments'); + // Do not make a string if comments are closed and there are currently + // zero comments. + if ($node->comment != COMMENT_NODE_CLOSED || $comments > 0) { + return format_plural($comments, '1 comment', '@count comments'); + } } - return ''; } /** |