Make WordPress Core

Changeset 432


Ignore:
Timestamp:
10/07/2003 09:48:32 PM (22 years ago)
Author:
emc3
Message:

Added checks to category functions for empty results.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/b2-include/b2template.functions.php

    r413 r432  
    10481048        echo "\t<option value='all'>$all</option>\n";
    10491049    }
    1050     foreach ($categories as $category) {
    1051         $cat_name = apply_filters('list_cats', $category->cat_name);
    1052         echo "\t<option value=\"".$category->cat_ID."\"";
    1053         if ($category->cat_ID == $cat)
    1054             echo ' selected="selected"';
    1055         echo '>'.stripslashes($cat_name);
    1056         if (intval($optioncount) == 1) {
    1057             echo '&nbsp;&nbsp;('.$category->cat_count.')';
    1058         }
    1059         if (intval($optiondates) == 1) {
    1060             echo '&nbsp;&nbsp;'.$category->lastday.'/'.$category->lastmonth;
    1061         }
    1062         echo "</option>\n";
     1050    if ($categories) {
     1051        foreach ($categories as $category) {
     1052            $cat_name = apply_filters('list_cats', $category->cat_name);
     1053            echo "\t<option value=\"".$category->cat_ID."\"";
     1054            if ($category->cat_ID == $cat)
     1055                echo ' selected="selected"';
     1056            echo '>'.stripslashes($cat_name);
     1057            if (intval($optioncount) == 1) {
     1058                echo '&nbsp;&nbsp;('.$category->cat_count.')';
     1059            }
     1060            if (intval($optiondates) == 1) {
     1061                echo '&nbsp;&nbsp;'.$category->lastday.'/'.$category->lastmonth;
     1062            }
     1063            echo "</option>\n";
     1064        }
    10631065    }
    10641066    echo "</select>\n";
     
    10881090
    10891091    $categories = $wpdb->get_results($query);
     1092
     1093    if (!$categories) {
     1094        if ($list) {
     1095            $before = '<li>';
     1096            $after = '</li>';
     1097        }
     1098        echo $before . "No categories" . $after . "\n";
     1099        return;
     1100    }
    10901101    ++$querycount;
    10911102    if (intval($optionall) == 1) {
     
    10951106        else echo "\t$link<br />\n";
    10961107    }
     1108
    10971109    foreach ($categories as $category) {
    10981110        $cat_name = apply_filters('list_cats', $category->cat_name);
Note: See TracChangeset for help on using the changeset viewer.