From 240c3ea9d84c806290015d7d2a2021188792750c Mon Sep 17 00:00:00 2001 From: emc3 Date: Tue, 7 Oct 2003 21:48:32 +0000 Subject: [PATCH] Added checks to category functions for empty results. git-svn-id: http://svn.automattic.com/wordpress/trunk@432 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- b2-include/b2template.functions.php | 38 +++++++++++++++++++---------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/b2-include/b2template.functions.php b/b2-include/b2template.functions.php index 113173e04..8804327d1 100644 --- a/b2-include/b2template.functions.php +++ b/b2-include/b2template.functions.php @@ -1047,19 +1047,21 @@ function dropdown_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_ $all = apply_filters('list_cats', $all); echo "\t\n"; } - foreach ($categories as $category) { - $cat_name = apply_filters('list_cats', $category->cat_name); - echo "\t\n"; + if ($categories) { + foreach ($categories as $category) { + $cat_name = apply_filters('list_cats', $category->cat_name); + echo "\t\n"; + } } echo "\n"; } @@ -1087,6 +1089,15 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde $query .= " ORDER BY $sort_column $sort_order, post_date DESC"; $categories = $wpdb->get_results($query); + + if (!$categories) { + if ($list) { + $before = '
  • '; + $after = '
  • '; + } + echo $before . "No categories" . $after . "\n"; + return; + } ++$querycount; if (intval($optionall) == 1) { $all = apply_filters('list_cats', $all); @@ -1094,6 +1105,7 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde if ($list) echo "\n\t
  • $link
  • "; else echo "\t$link
    \n"; } + foreach ($categories as $category) { $cat_name = apply_filters('list_cats', $category->cat_name); $link = '';