- Patch 7897: don't show blocks if they have no content

4.7.x
Dries Buytaert 2005-07-02 11:58:16 +00:00
parent d9d21371df
commit aa75f0a18c
4 changed files with 36 additions and 30 deletions

View File

@ -277,12 +277,15 @@ 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));
$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;
}
}
}
}
?>

View File

@ -277,12 +277,15 @@ 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));
$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;
}
}
}
}
?>

View File

@ -447,28 +447,28 @@ 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 />');
if (count($content)) {
$block['content'] = implode($content, '<br />');
$block['subject'] = t('Popular content');
$block['content'] = $output;
return $block;
}
}
}
}
/**
* It is possible to adjust the width of columns generated by the

View File

@ -447,28 +447,28 @@ 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 />');
if (count($content)) {
$block['content'] = implode($content, '<br />');
$block['subject'] = t('Popular content');
$block['content'] = $output;
return $block;
}
}
}
}
/**
* It is possible to adjust the width of columns generated by the