From 96bfc650bc1f4430654575b8872e77c90bb8d50c Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Mon, 26 Apr 2010 14:26:46 +0000 Subject: - Patch #537278 by jhodgdon, caelon, dtarc: search results show comment count for content types where comments are disabled. --- modules/comment/comment.module | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'modules/comment') 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 ''; } /** -- cgit v1.2.3