Jump to content

Navigation Problems

- - - - -

  • Please log in to reply
No replies to this topic

#1
doheja07

doheja07

    Learning Programmer

  • Members
  • PipPipPip
  • 31 posts
Could somebody help me? I have built a navigation funtion that only show the subcategories when the category they belong to is selected. It is three layers deep. The problem is as soon as I select a subcategory, the category is no longer selected. This causes the navigation menu to only show categories again. How can I fix it so that the list of subcategories stays open when a subcategory is selected? I would also like to be able to do the same thing for sub-subcategories within a subcategory. Here is the navigation function.
function navigation($sel_category, $sel_subcategory, $sel_subsubcategory, $public = false) {
$output = "<ul class=\"subjects\">";
$category_set = get_all_categories($public = false);
while ($category = mysql_fetch_array($category_set)) {
$output .=  "<li";
if($category["id"] == $sel_category['id']) { $output .= " class=\"selected\"";}
$output .= "><a href=\"products.php?cat=" . urlencode($category["id"]) .
"\">{$category["cat_name"]}</a></li>";
if($category["id"] == $sel_category['id']) {
$subcategory_set = get_subcategories_for_category($category["id"]);	
$output .= "<ul>";
while ($subcategory = mysql_fetch_array($subcategory_set)) {
$output .= "<li";
if($subcategory["id"] == $sel_subcategory['id']) { $output .= " class=\"selected\"";}
$output .= "><a href=\"products.php?subcat=" . urlencode($subcategory["id"]) .
"\">{$subcategory["subcat_name"]}</a></li>";
if($subcategory["id"] == $sel_subcategory['id']) {
$subsubcategory_set = get_subsubcategories_for_subcategory($subcategory["id"]);
$output .= "<ul>";
while ($subsubcategory = mysql_fetch_array($subsubcategory_set)) {
$output .= "<li";
if($subsubcategory["id"] == $sel_subsubcategory['id']) { $output .= " class=\"selected\"";}
$output .= "><a href=\products.php?subsubcat=" . urlencode($subsubcategory["id"]) . 
"\">{$subsubcategory["subsubcat_name"]}</a></li>";
}
$output .= "</ul>";
}
}
$output .= "</ul>";
}
}
$output .= "</ul>";
return $output;
}

Edited by WingedPanther, 19 May 2009 - 07:33 AM.
add code tags (the # button)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users