ATutor

Learning Management Tools







Pages:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15


Customize categories


  • 2005-04-11 10:14:38

    Customize categories

    Hi,

    I'm trying to add a logo behind the list of categories.
    I've added a field "logo" in AT_courses_cat, but I can't display my logo (vars pb) :

    [i]browse_categories.inc.php[/i]
    [quote] if (!defined('AT_INCLUDE_PATH')) { exit; }

    $sql = "SELECT * FROM ".TABLE_PREFIX."course_cats ORDER BY cat_name ";
    $result = mysql_query($sql, $db);
    if (mysql_num_rows($result) == 0) {
    $msg->addInfo('NO_CATEGORIES');
    } else {
    while($row = mysql_fetch_assoc($result)){
    $current_cats[$row['cat_id']] = $row['cat_name'];
    $parent_cats[$row['cat_id']] = $row['cat_parent'];
    $cat_cats[$row['cat_id']] = $row['cat_id'];
    [b]$logo_cats[$row['cat_id']] = $row['logo'];[/b]

    }
    }

    // count the number of courses in each category
    $sql = "SELECT cat_id from ".TABLE_PREFIX."courses WHERE hide=0";
    $result = mysql_query($sql, $db);

    while($row = mysql_fetch_array($result)){
    $cat_count[$row['cat_id']][$i] = $i++;
    }

    function print_parent_cats($parent_cat_id, &$cats, $cat_row) {
    $my_cats = $cats[$parent_cat_id];
    $new_depth = ($old_depth - $depth);
    global $cat_count;
    echo '<ul>'."\n";
    foreach ($my_cats as $cat) {
    echo '<li><a href="'.$_SERVER['PHP_SELF'].'?current_cat='.$cat['cat_id'].SEP.'show_courses='.$cat['cat_id'].'">';
    if($cat['cat_id'] != $cat_row){
    echo $cat['cat_name'][b].' <img src="images/'.$cat['logo'].'" border="0"/>'[/b];
    }else{
    echo '<strong>'.$cat['cat_name'].'[b] <img src="images/'.$cat['logo'].'" border="0"/>[/b]</strong>';
    }
    echo '</a> <small>';
    echo '( '.count($cat_count[$cat['cat_id']]).' )</small>';

    if (is_array($cats[$cat['cat_id']]) && ($cat['cat_id'] !== 0) ) {
    print_parent_cats($cat['cat_id'], $cats, $cat_row, $depth+1);
    }
    echo '</li>';
    }
    echo '</ul>';
    }
    [/quote]