Changeset 259 for trunk/b2-include/b2template.functions.php
- Timestamp:
- 07/19/2003 10:55:18 PM (23 years ago)
- File:
-
- 1 edited
-
trunk/b2-include/b2template.functions.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/b2-include/b2template.functions.php
r253 r259 861 861 862 862 // out of the b2 loop 863 function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = 'blah', $list = true) { 864 global $tablecategories, $querycount, $wpdb; 863 function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', 864 $file = 'blah', $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1) { 865 global $tablecategories, $tableposts, $querycount, $wpdb; 865 866 global $pagenow; 866 867 global $querystring_start, $querystring_equal, $querystring_separator; 867 $file = ($file == 'blah') ? $pagenow : $file; 868 if (($file == 'blah') || ($file == '')) { 869 $file = $pagenow; 870 } 868 871 $sort_column = 'cat_'.$sort_column; 869 $categories = $wpdb->get_results("SELECT * FROM $tablecategories WHERE cat_ID > 0 ORDER BY $sort_column $sort_order"); 872 873 $query = " SELECT cat_ID, cat_name,"; 874 $query .= " COUNT($tableposts.ID) AS cat_count,"; 875 $query .= " DAYOFMONTH(MAX(post_date)) AS lastday, MONTH(MAX(post_date)) AS lastmonth"; 876 $query .= " FROM $tablecategories LEFT JOIN $tableposts ON cat_ID = post_category"; 877 $query .= " WHERE cat_ID > 0 "; 878 $query .= " GROUP BY post_category "; 879 if (intval($hide_empty) == 1) { 880 $query .= " HAVING cat_count > 0"; 881 } 882 $query .= " ORDER BY $sort_column $sort_order, post_date DESC"; 883 884 $categories = $wpdb->get_results($query); 870 885 ++$querycount; 871 886 if (intval($optionall) == 1) { 872 887 $all = apply_filters('list_cats', $all); 873 if ($list) echo "\n\t<li><a href=\"".$file.$querystring_start.'cat'.$querystring_equal.'all">'.$all."</a></li>"; 874 else echo "\t<a href=\"".$file.$querystring_start.'cat'.$querystring_equal.'all">'.$all."</a><br />\n"; 888 $link = "<a href=\"".$file.$querystring_start.'cat'.$querystring_equal.'all">'.$all."</a>"; 889 if ($list) echo "\n\t<li>$link</li>"; 890 else echo "\t$link<br />\n"; 875 891 } 876 892 foreach ($categories as $category) { 877 893 $cat_name = apply_filters('list_cats', $category->cat_name); 894 $link = "<a href=\"".$file.$querystring_start.'cat'.$querystring_equal.$category->cat_ID.'">'; 895 $link .= stripslashes($cat_name)."</a>"; 896 if (intval($optioncount) == 1) { 897 $link .= " (".$category->cat_count.")"; 898 } 899 if (intval($optiondates) == 1) { 900 $link .= " ".$category->lastday."/".$category->lastmonth.""; 901 } 902 $link .= "</a>"; 878 903 if ($list) { 879 echo "\n\t<li><a href=\"".$file.$querystring_start.'cat'.$querystring_equal.$category->cat_ID.'">'; 880 echo stripslashes($cat_name)."</a></li>"; 904 echo "\n\t<li>$link</li>"; 881 905 } else { 882 echo "\t<a href=\"".$file.$querystring_start.'cat'.$querystring_equal.$category->cat_ID.'">'; 883 echo stripslashes($cat_name)."</a><br />\n"; 906 echo "\t$link<br />\n"; 884 907 } 885 908 }
Note: See TracChangeset
for help on using the changeset viewer.