From aa75f0a18c06950d39778fab310086257c4909d6 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 2 Jul 2005 11:58:16 +0000 Subject: - Patch 7897: don't show blocks if they have no content --- modules/blog/blog.module | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'modules/blog/blog.module') diff --git a/modules/blog/blog.module b/modules/blog/blog.module index 31d4689b5..26c2c43aa 100644 --- a/modules/blog/blog.module +++ b/modules/blog/blog.module @@ -277,11 +277,14 @@ function blog_block($op = 'list', $delta = 0) { } else if ($op == 'view') { if (user_access('access content')) { - $block['content'] = node_title_list(db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC"), 0, 10)); - $block['content'] .= ''; - $block['subject'] = t('Recent blog posts'); + $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC"), 0, 10); + if (db_num_rows($result)) { + $block['content'] = node_title_list($result); + $block['content'] .= ''; + $block['subject'] = t('Recent blog posts'); + return $block; + } } - return $block; } } -- cgit v1.2.3