diff options
-rw-r--r-- | modules/blog.module | 11 | ||||
-rw-r--r-- | modules/blog/blog.module | 11 | ||||
-rw-r--r-- | modules/statistics.module | 22 | ||||
-rw-r--r-- | modules/statistics/statistics.module | 22 |
4 files changed, 36 insertions, 30 deletions
diff --git a/modules/blog.module b/modules/blog.module index 31d4689b5..26c2c43aa 100644 --- a/modules/blog.module +++ b/modules/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'] .= '<div class="more-link">'. l(t('more'), 'blog', array('title' => t('Read the latest blog entries.'))) .'</div>'; - $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'] .= '<div class="more-link">'. l(t('more'), 'blog', array('title' => t('Read the latest blog entries.'))) .'</div>'; + $block['subject'] = t('Recent blog posts'); + return $block; + } } - return $block; } } 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'] .= '<div class="more-link">'. l(t('more'), 'blog', array('title' => t('Read the latest blog entries.'))) .'</div>'; - $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'] .= '<div class="more-link">'. l(t('more'), 'blog', array('title' => t('Read the latest blog entries.'))) .'</div>'; + $block['subject'] = t('Recent blog posts'); + return $block; + } } - return $block; } } diff --git a/modules/statistics.module b/modules/statistics.module index 88e1e0daa..f29d9f1f4 100644 --- a/modules/statistics.module +++ b/modules/statistics.module @@ -447,25 +447,25 @@ function statistics_block($op = 'list', $delta = 0, $edit = array()) { $content = array(); $daytop = variable_get('statistics_block_top_day_num', 0); - if ($daytop) { - $content[] = node_title_list(statistics_title_list('daycount', $daytop), t("Today's:")); + if ($daytop && ($result = statistics_title_list('daycount', $daytop)) && db_num_rows($result)) { + $content[] = node_title_list($result, t("Today's:")); } $alltimetop = variable_get('statistics_block_top_all_num', 0); - if ($alltimetop) { - $content[] = node_title_list(statistics_title_list('totalcount', $alltimetop), t('All time:')); + if ($alltimetop && ($result = statistics_title_list('totalcount', $alltimetop)) && db_num_rows($result)) { + $content[] = node_title_list($result, t('All time:')); } $lasttop = variable_get('statistics_block_top_last_num', 0); - if ($lasttop) { - $content[] = node_title_list(statistics_title_list('timestamp', $lasttop), t('Last viewed:')); + if ($lasttop && ($result = statistics_title_list('timestamp', $lasttop)) && db_num_rows($result)) { + $content[] = node_title_list($result, t('Last viewed:')); } - $output = implode($content, '<br />'); - $block['subject'] = t('Popular content'); - $block['content'] = $output; - - return $block; + if (count($content)) { + $block['content'] = implode($content, '<br />'); + $block['subject'] = t('Popular content'); + return $block; + } } } } diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module index 88e1e0daa..f29d9f1f4 100644 --- a/modules/statistics/statistics.module +++ b/modules/statistics/statistics.module @@ -447,25 +447,25 @@ function statistics_block($op = 'list', $delta = 0, $edit = array()) { $content = array(); $daytop = variable_get('statistics_block_top_day_num', 0); - if ($daytop) { - $content[] = node_title_list(statistics_title_list('daycount', $daytop), t("Today's:")); + if ($daytop && ($result = statistics_title_list('daycount', $daytop)) && db_num_rows($result)) { + $content[] = node_title_list($result, t("Today's:")); } $alltimetop = variable_get('statistics_block_top_all_num', 0); - if ($alltimetop) { - $content[] = node_title_list(statistics_title_list('totalcount', $alltimetop), t('All time:')); + if ($alltimetop && ($result = statistics_title_list('totalcount', $alltimetop)) && db_num_rows($result)) { + $content[] = node_title_list($result, t('All time:')); } $lasttop = variable_get('statistics_block_top_last_num', 0); - if ($lasttop) { - $content[] = node_title_list(statistics_title_list('timestamp', $lasttop), t('Last viewed:')); + if ($lasttop && ($result = statistics_title_list('timestamp', $lasttop)) && db_num_rows($result)) { + $content[] = node_title_list($result, t('Last viewed:')); } - $output = implode($content, '<br />'); - $block['subject'] = t('Popular content'); - $block['content'] = $output; - - return $block; + if (count($content)) { + $block['content'] = implode($content, '<br />'); + $block['subject'] = t('Popular content'); + return $block; + } } } } |