We have a webshop with lots of products and some categories have several subcategories, subcategories of subcategories etc etc. When no category is chosen, it displays only the main categories and when you open a category, it will drop down *all* the subcategories. My intention is to only show subcategory level 2 ($s['cs_category_level'] == 2) when the site drop downs the subcategories which should reduce their amount notably. Sadly, my scripting skills aren't good enough to actually add anything new to the code rather than copypasting the portions of the old code, so could someone help out with it?:
//-----------------------------------------------------------------// Lets show the dynamic links of the product categories.//----------------------------------------------------------------- $result = mysql_query ("SELECT * FROM $clover_shop_categories WHERE cs_category_title IS NOT NULL ORDER BY cs_category_listing_position asc"); if (mysql_num_rows ($result)) { unset ($navecho_open, $nav_echo_closed, $nav_open_this_one); echo "<TABLE cellpadding=2 cellspacing=0 border=0 width=\"100%\ height=\"100%\">\n\n"; while ($s = mysql_fetch_array ($result)) { if ($s['cs_category_level'] == 1) { if ($nav_open_this_one && $nav_echo_open) { echo $nav_echo_open; } else { echo $nav_echo_closed; } unset ($nav_echo_open, $nav_echo_closed, $nav_open_this_one); } $nav_echo_open .= "<TR><TD class=\"nav_open\"><P class=\"nav_open\">"; if ($s['cs_category_level'] != 1) { for ($i = 2; $i <= $s['cs_category_level']; $i++) { if ($i == $s['cs_category_level']) { $nav_echo_open .= " <img src=\"logos/tree_corner.gif\" width=\"11\" height=\"11\" alt=\"\">"; } else { $nav_echo_open .= " <img src=\"logos/tree_empty.gif\" width=\"11\" height=\"11\" alt=\"\">"; } } } if ($c == $s[cs_category_id]) $nav_echo_open .= "<B>"; $nav_echo_open .= "<a href=\"$config[cs_setting_cat_url]/product_catalog.php?c=$s[cs_category_id]\" class=\"nav_open\">$s[cs_category_title]</a>"; if ($c == $s[cs_category_id]) $nav_echo_open .= "</B>"; $nav_echo_open .= "</P></TD></TR>\n\n"; if ($s['cs_category_level'] == 1) { $nav_echo_closed .= "<TR><TD class=\"nav_closed\"><P class=\"nav_closed\">"; for ($i = 2; $i <= $s['cs_category_level']; $i++) { if ($i == $s['cs_category_level']) { $nav_echo_closed .= " <img src=\"logos/tree_corner.gif\" width=\"11\" height=\"11\" alt=\"\">"; } else { $nav_echo_closed .= " <img src=\"logos/tree_empty.gif\" width=\"11\" height=\"11\" alt=\"\">"; } } $nav_echo_closed .= "<a href=\"$config[cs_setting_cat_url]/product_catalog.php?c=$s[cs_category_id]\" class=\"nav_closed\">$s[cs_category_title]</a>"; $nav_echo_closed .= "</P></TD></TR>\n\n"; } if ($c == $s['cs_category_id']) $nav_open_this_one = 1; } if ($nav_open_this_one && $nav_echo_open) { echo $nav_echo_open; } else { echo $nav_echo_closed; } echo "</TABLE>\n\n"; unset ($nav_echo_open, $nav_echo_closed, $nav_open_this_one); }