Guest Posted January 25, 2006 Posted January 25, 2006 When I go to a category path url such as index.php?cPath=85 or some such, then any subcategory in that category is listed on the main page. This is good, but how can I list all the subcategories of each subcategory on that same page? I am looking for something like: Category 1 Page ----------------------------------------- Subcategory1 SubSubcategory1_1 SubSubCategory1_2 SubSubCategory1_3 SubSubcategory1_4 SubSubCategory1_5 SubSubCategory1_6 SubSubcategory1_7 SubSubCategory1_8 SubSubCategory1_9 SubSubcategory1_10 SubSubCategory1_11 SubSubCategory1_12 Subcategory2 SubSubcategory2_1 SubSubCategory2_2 SubSubCategory2_3 SubSubcategory2_4 SubSubCategory2_5 SubSubCategory2_6 SubSubcategory2_7 SubSubCategory2_8 SubSubCategory2_9 SubSubcategory2_10 SubSubCategory2_11 SubSubCategory2_12 I didn't find anything searching in the forum, but I may have missed a thread or such, can someone point me to a thread or contribution or some instruction on how to do this?
Guest Posted January 27, 2006 Posted January 27, 2006 Its the catalog\index.php Find this code: if (isset($cPath) && strpos('_', $cPath)) { // check to see if there are deeper categories within the current category $category_links = array_reverse($cPath_array); for($i=0, $n=sizeof($category_links); $i<$n; $i++) { $categories_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'"); $categories = tep_db_fetch_array($categories_query); if ($categories['total'] < 1) { // do nothing, go through the loop } else { $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name"); break; // we've found the deepest category the customer is in } } } else { $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name"); } you only need the last query so replace it with $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name"); backup and try it.
Guest Posted January 27, 2006 Posted January 27, 2006 Its the catalog\index.php Find this code: if (isset($cPath) && strpos('_', $cPath)) { // check to see if there are deeper categories within the current category $category_links = array_reverse($cPath_array); for($i=0, $n=sizeof($category_links); $i<$n; $i++) { $categories_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'"); $categories = tep_db_fetch_array($categories_query); if ($categories['total'] < 1) { // do nothing, go through the loop } else { $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name"); break; // we've found the deepest category the customer is in } } } else { $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name"); } you only need the last query so replace it with $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name"); backup and try it. Actually, I fixed it, and achieved what I wanted by doing this: <td><table border="0" width="100%" cellspacing="10" cellpadding="0"> <?php if (isset($cPath) && strpos('_', $cPath)) { // check to see if there are deeper categories within the current category $category_links = array_reverse($cPath_array); for($i=0, $n=sizeof($category_links); $i<$n; $i++) { $categories_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'"); $categories = tep_db_fetch_array($categories_query); if ($categories['total'] < 1) { // do nothing, go through the loop } else { $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name"); break; // we've found the deepest category the customer is in } } } else { $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name"); } $number_of_categories = tep_db_num_rows($categories_query); $rows = 0; while ($categories = tep_db_fetch_array($categories_query)) { $rows++; $cPath_new = tep_get_path($categories['categories_id']); $width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%'; echo ' <tr>' . "\n"; echo ' <td align="left" class="IH_Series_header" colspan="' . MAX_DISPLAY_CATEGORIES_PER_ROW . '" valign="top"><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . $categories['categories_name'] . '</a></td>' . "\n"; echo ' </tr>' . "\n"; //if ((($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != $number_of_categories)) { // echo ' </tr>' . "\n"; // echo ' <tr>' . "\n"; //} // Additional subsubcategory listing code - BEGIN /* echo ' </tr>' . "\n";*/ echo ' <tr>' . "\n"; $cPath_new2 = $cPath . '_' . $categories['categories_id']; $cPath_array_new = tep_parse_category_path($cPath_new2); $current_sub_category_id = $cPath_array_new[(sizeof($cPath_array_new)-1)]; if (isset($cPath_new2) && strpos('_', $cPath_new2)) { $sub_category_links = array_reverse($cPath_array_new); for($i=0, $n=sizeof($sub_category_links); $i<$n; $i++) { $sub_categories_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$sub_category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'"); $sub_categories = tep_db_fetch_array($sub_categories_query); if ($sub_categories['total'] < 1) { // do nothing, go through the loop } else { $sub_categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$sub_category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name"); break; // we've found the deepest category the customer is in } } } else { $sub_categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$current_sub_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name"); } $number_of_sub_categories = tep_db_num_rows($sub_categories_query); $sub_rows = 0; while ($sub_categories = tep_db_fetch_array($sub_categories_query)) { $sub_rows++; $sub_cPath_new = tep_get_path($sub_categories['categories_id']); $sub_width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%'; echo ' <td align="left" class="smallText" width="' . $width . '" valign="top"><a href="' . tep_href_link(FILENAME_DEFAULT, $sub_cPath_new) . '">' . tep_image(DIR_WS_IMAGES . $sub_categories['categories_image'], $sub_categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . $sub_categories['categories_name'] . '</a></td>' . "\n"; if ((($sub_rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($sub_rows / MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($sub_rows != $number_of_sub_categories)) { echo ' </tr>' . "\n"; /* echo ' <tr>' . "\n";*/ } } echo ' </tr>' . "\n"; /* echo ' <tr>' . "\n";*/ // Additional subsubcategory listing code - END } // needed for the new products module shown below $new_products_category_id = $current_category_id; ?> </table></td>
Guest Posted January 29, 2006 Posted January 29, 2006 This looks very interesting and I will come back to it but I need to be one step behind this stage. I keep seeing references to sub categories but I can't see how to create them anywhere. I've tried searching the knowledge base with those words but only get references to the attributes. Are attrributes being used as sub categories ? Any tips gratefully received. Tom
Guest Posted January 31, 2006 Posted January 31, 2006 you create them with osc admin tools much like you create a new product. You just click "new category" in the admin products listing screen
Guest Posted February 3, 2006 Posted February 3, 2006 I thought I would put up a sample of what the end result can look like: http://www.theinkhut.com/catalog/index.php?cPath=34_35 I find this to be very very useful.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.