Make WordPress Core


Ignore:
Timestamp:
12/04/2003 10:53:15 PM (22 years ago)
Author:
saxmatt
Message:

Alpha multiple category support.

File:
1 edited

Legend:

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

    r559 r565  
    417417        '%monthnum%',
    418418        '%day%',
    419         '%postname%'
     419        '%postname%',
     420        '%post_id%'
    420421    );
    421422    if (!$id) {
     
    441442                date('n', $unixtime),
    442443                date('j', $unixtime),
    443                 $idpost->post_name
     444                $idpost->post_name,
     445                $id
    444446            );
    445447            return $siteurl . str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure'));
     
    12241226/***** Category tags *****/
    12251227
    1226 function get_category_link($echo = false, $file='') {
    1227     global $post, $querystring_start, $querystring_equal, $siteurl, $blogfilename;
    1228     $cat_ID = $post->post_category;
    1229     if ($file == '') {
    1230         $file = "$siteurl/$blogfilename";
    1231     }
    1232     if ('http:' != substr($file,0,5)) {
    1233         $file = "$siteurl/$file";
    1234     }
    1235     $link = $file.$querystring_start.'cat'.$querystring_equal.$cat_ID;
    1236     if ($echo)
    1237         echo($link);
    1238     return $link;
    1239 }
    1240 
    1241 function the_category() {
    1242     $category = get_the_category();
    1243     $category = apply_filters('the_category', $category);
    1244     echo convert_chars($category, 'html');
    1245 }
     1228function get_the_category() {
     1229    global $post, $tablecategories, $tablepost2cat, $wpdb;
     1230    $categories = $wpdb->get_results("
     1231        SELECT category_id, cat_name, category_nicename
     1232        FROM  $tablecategories, $tablepost2cat
     1233        WHERE $tablepost2cat.category_id = cat_ID AND $tablepost2cat.post_id = $post->ID
     1234        ");
     1235
     1236    return $categories;
     1237}
     1238
     1239function get_category_link($echo = false, $category_id) {
     1240    global $wpdb, $tablecategories, $post, $querystring_start, $querystring_equal, $siteurl, $blogfilename;
     1241    $cat_ID = $category_id;
     1242    $permalink_structure = get_settings('permalink_structure');
     1243   
     1244    if ('' == $permalink_structure) {
     1245        $file = "$siteurl/$blogfilename";
     1246        $link = $file.$querystring_start.'cat'.$querystring_equal.$cat_ID;
     1247    } else {
     1248        $category_nicename = $wpdb->get_var("SELECT category_nicename FROM $tablecategories WHERE cat_ID = $category_id");
     1249        // Get any static stuff from the front
     1250        $front = substr($permalink_structure, 0, strpos($permalink_structure, '%'));
     1251        $link = $front . 'category/' . $category_nicename;
     1252    }
     1253
     1254    if ($echo) echo $link;
     1255    return $link;
     1256}
     1257
     1258function the_category($seperator = '') {
     1259    $categories = get_the_category();
     1260    if ('' == $seperator) {
     1261        echo '<ul class="post-categories">';
     1262        foreach ($categories as $category) {
     1263            echo "\n\t<li><a href='" . get_category_link(0, $category->category_id) . "' title='View all posts in $category->cat_name'>$category->cat_name</a></li>";
     1264        }
     1265        echo '</ul>';
     1266    } else {
     1267        $i = 0;
     1268        foreach ($categories as $category) {
     1269            if (0 < $i) echo $seperator . ' ';
     1270            echo "<a href='" . get_category_link(0, $category->category_id) . "' title='View all posts in $category->cat_name'>$category->cat_name</a>";
     1271            ++$i;
     1272        }
     1273    }
     1274}
     1275
    12461276function the_category_rss() {
    12471277    echo convert_chars(strip_tags(get_the_category()), 'xml');
     
    12531283}
    12541284
    1255 function get_the_category() {
    1256     global $post, $tablecategories, $querycount, $cache_categories, $use_cache, $wpdb;
    1257     $cat_ID = $post->post_category;
    1258     if ((empty($cache_categories[$cat_ID])) OR (!$use_cache)) {
    1259         $cat_name = $wpdb->get_var("SELECT cat_name FROM $tablecategories WHERE cat_ID = '$cat_ID'");
    1260         ++$querycount;
    1261         $cache_categories[$cat_ID] = $cat_name;
    1262     } else {
    1263         $cat_name = $cache_categories[$cat_ID];
    1264     }
    1265     return(stripslashes($cat_name));
    1266 }
     1285
    12671286
    12681287function get_the_category_by_ID($cat_ID) {
Note: See TracChangeset for help on using the changeset viewer.