zxedxz Posted January 23, 2005 Posted January 23, 2005 I'm not sure if this is the right place to post this question, but i thought this forum is the one that suit is the most. I'm using the dynamic dhtml menu with STS contrib. Since i already have the menu horizontally, i don't need the category box anymore. But i want to display only the subcategory of a selected category. That mean, When i click on one category, it opens that category, but display the subcategories that it this category has in the left side. Also, even thought i choose one subcategory, i want the subcategory box to stay. Is there such contribution? Please help. Thanks. Quote
zxedxz Posted January 24, 2005 Author Posted January 24, 2005 Help, Still can't figure out how to do it. Quote
king_of_comedy Posted January 24, 2005 Posted January 24, 2005 Try this: function show_subcategories($counter) { global $fooa, $subcategories_string, $id, $HTTP_GET_VARS; $cPath_new = 'cPath=' . $fooa[$counter]['path']; $subcategories_string .= '<table border="0" cellspacing="1" cellpadding="1" width="100%"><tr><td nowrap class="boxTextc' . $fooa[$counter]['level'] . '"> '; $subcategories_string .= '<a class="boxTextd' . $fooa[$counter]['level'] . '" href="'; $subcategories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">'; // display category name $subcategories_string .= $fooa[$counter]['name']; $subcategories_string .= '</a> '; if ($fooa[$counter]['next_id']) { $subcategories_string .= '</td></tr></table>'; show_subcategories($fooa[$counter]['next_id']); }else{ $subcategories_string .= '</td></tr></table>'; } } ?> <!-- categories //--> <tr> <td> <?php if ($cPath) { $subcategories_string = ''; $new_path = ''; $id = split('_', $cPath); reset($id); while (list($key, $value) = each($id)) { unset($prev_id); unset($first_id); $subcategories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . $value . "' and c.categories_id = cd.categories_id and cd.language_id='" . $languages_id ."' order by sort_order, cd.categories_name"); $subcategory_check = tep_db_num_rows($subcategories_query); if ($subcategory_check > 0) { $new_path .= $value; while ($row = tep_db_fetch_array($subcategories_query)) { $fooa[$row['categories_id']] = array( 'name' => $row['categories_name'], 'parent' => $row['parent_id'], 'level' => $key+1, 'path' => $new_path . '_' . $row['categories_id'], 'next_id' => false ); if (isset($prev_id)) { $fooa[$prev_id]['next_id'] = $row['categories_id']; } $prev_id = $row['categories_id']; if (!isset($first_id)) { $first_id = $row['categories_id']; } $last_id = $row['categories_id']; } $fooa[$last_id]['next_id'] = $fooa[$value]['next_id']; $fooa[$value]['next_id'] = $first_id; $new_path .= '_'; } else { break; } } } if ($id[0] != ''){ show_subcategories($id[0]); echo $subcategories_string; }else{ echo " "; } ?> </td> </tr> <!-- categories_eof //--> Quote
zxedxz Posted January 27, 2005 Author Posted January 27, 2005 Isn't this the subcategroy part of the tab menu contribution? it display the subcategories in horizontal. What I want is keep it on a box as it were the standart categories (one top of other). Also, please be more details on which files to modify since i'm not very familiar with oscommerce. Thanks Quote
zxedxz Posted January 30, 2005 Author Posted January 30, 2005 Still need help. Someone knows how to do it? I don't know if i'm very unlucky or what i'm trying to do is too complex? I ever seem to get an answer from all the many post that i have made, in this board and in other boards. Quote
rcr121 Posted June 15, 2005 Posted June 15, 2005 Try this: Chris, Your code works perfectly---except for ONE tiny thing. For some reason, an extranious 'ahref' is created at the top of the subcat. list. When I try to add an image next to the URL, I end up with an extra "row" with just the image. When I looked at the source, I noticed the URL (which doesn't have a cpath variable)...it is there whether I have the image on or not, but it only causes a problem with the image... Would you have any idea why this is happening?! THANKS RCR Quote
rcr121 Posted June 15, 2005 Posted June 15, 2005 Try this: Chris, Your code works perfectly---except for ONE tiny thing. For some reason, an extranious 'ahref' is created at the top of the subcat. list. When I try to add an image next to the URL, I end up with an extra "row" with just the image. When I looked at the source, I noticed the URL (which doesn't have a cpath variable)...it is there whether I have the image on or not, but it only causes a problem with the image... Would you have any idea why this is happening?! THANKS RCR <{POST_SNAPBACK}> I figured it out! Or, at least, I got it to do what I wanted...! Changed: if ($id[0] != ''){ show_subcategories($id[0]); echo $subcategories_string; }else{ echo " "; } to: if ($id[1] != ''){ show_subcategories($id[1]); echo $subcategories_string; }else{ echo " "; } And it works brilliantly! Thanks for a great mini-mod/hack Chris. RCR Quote
rcr121 Posted June 15, 2005 Posted June 15, 2005 Well, I'm a doofus. IT DID NOT WORK. What is happening, is that is loading the parent id, with out any text for the ahref, so I get a blank row in my categories box where the image shows...any help would be appreciated. RCR Quote
L!mit Posted November 2, 2005 Posted November 2, 2005 The code below works great there is one issue that I can?t seem to resolve. - When you click on a manufacture link from the "manufactures" box all the sub-cats disappear. Can anybody please help resolve this so that the subcats will display when clicking on manufactures links. Try this: function show_subcategories($counter) { global $fooa, $subcategories_string, $id, $HTTP_GET_VARS; $cPath_new = 'cPath=' . $fooa[$counter]['path']; $subcategories_string .= '<table border="0" cellspacing="1" cellpadding="1" width="100%"><tr><td nowrap class="boxTextc' . $fooa[$counter]['level'] . '"> '; $subcategories_string .= '<a class="boxTextd' . $fooa[$counter]['level'] . '" href="'; $subcategories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">'; // display category name $subcategories_string .= $fooa[$counter]['name']; $subcategories_string .= '</a> '; if ($fooa[$counter]['next_id']) { $subcategories_string .= '</td></tr></table>'; show_subcategories($fooa[$counter]['next_id']); }else{ $subcategories_string .= '</td></tr></table>'; } } ?> <!-- categories //--> <tr> <td> <?php if ($cPath) { $subcategories_string = ''; $new_path = ''; $id = split('_', $cPath); reset($id); while (list($key, $value) = each($id)) { unset($prev_id); unset($first_id); $subcategories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . $value . "' and c.categories_id = cd.categories_id and cd.language_id='" . $languages_id ."' order by sort_order, cd.categories_name"); $subcategory_check = tep_db_num_rows($subcategories_query); if ($subcategory_check > 0) { $new_path .= $value; while ($row = tep_db_fetch_array($subcategories_query)) { $fooa[$row['categories_id']] = array( 'name' => $row['categories_name'], 'parent' => $row['parent_id'], 'level' => $key+1, 'path' => $new_path . '_' . $row['categories_id'], 'next_id' => false ); if (isset($prev_id)) { $fooa[$prev_id]['next_id'] = $row['categories_id']; } $prev_id = $row['categories_id']; if (!isset($first_id)) { $first_id = $row['categories_id']; } $last_id = $row['categories_id']; } $fooa[$last_id]['next_id'] = $fooa[$value]['next_id']; $fooa[$value]['next_id'] = $first_id; $new_path .= '_'; } else { break; } } } if ($id[0] != ''){ show_subcategories($id[0]); echo $subcategories_string; }else{ echo " "; } ?> </td> </tr> <!-- categories_eof //--> Quote
Kohn Posted March 30, 2007 Posted March 30, 2007 Anybody got this to work? I really need to just show the subcategories. The code below works great there is one issue that I can�t seem to resolve. - When you click on a manufacture link from the "manufactures" box all the sub-cats disappear. Can anybody please help resolve this so that the subcats will display when clicking on manufactures links. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.