Guest Posted January 15, 2005 Posted January 15, 2005 Im using the following code in my STS Tempate for a drop down category menu and I would like to know if it can be altered to only show main categories and one level of sub category and nothing more as the list it's currently generating is very long. $sts_block_name = 'catmenu'; require(STS_START_CAPTURE); echo "\n<!-- Start Category Menu -->\n"; echo tep_draw_form('goto', FILENAME_DEFAULT, 'get', ''); echo tep_draw_pull_down_menu('cPath', tep_get_category_tree(), $current_category_id, 'onChange="this.form.submit();"'); echo "</form>\n"; echo "<!-- End Category Menu -->\n"; require(STS_STOP_CAPTURE); $template['catmenu'] = $sts_block['catmenu']; function tep_get_category_tree($parent_id = '0', $spacing = '', $exclude = '', $category_tree_array = '', $include_itself = false) { global $languages_id; if (!is_array($category_tree_array)) $category_tree_array = array(); if ( (sizeof($category_tree_array) < 1) && ($exclude != '0') ) $category_tree_array[] = array('id' => '0', 'text' => "Catalog"); if ($include_itself) { $category_query = tep_db_query("select cd.categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " cd where cd.language_id = '" . (int)$languages_id . "' and cd.categories_id = '" . (int)$parent_id . "'"); $category = tep_db_fetch_array($category_query); $category_tree_array[] = array('id' => $parent_id, 'text' => $category['categories_name']); } $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and c.parent_id = '" . (int)$parent_id . "' order by c.sort_order, cd.categories_name"); while ($categories = tep_db_fetch_array($categories_query)) { if ($exclude != $categories['categories_id']) $category_tree_array[] = array('id' => $categories['categories_id'], 'text' => $spacing . $categories['categories_name']); $category_tree_array = tep_get_category_tree($categories['categories_id'], $spacing . ' ', $exclude, $category_tree_array); } return $category_tree_array; }
Guest Posted January 18, 2005 Posted January 18, 2005 Since nobody else is answering you and I'm afraid you'll keep posting it or bumping it here is you answer: YES it can be done and very easily. You use the function tep_get_category_tree() which will return the complete tree and only differentiates nested categories by a space (1 space for each nest). You will need to capture the array then strip the entries more than 2 nests. After you've filtered the category array that is returned from the function then pass that into the tep_draw_pull_down_menu() function. Bobby
Guest Posted January 19, 2005 Posted January 19, 2005 Cheers for the reply Chemo, Hahaha yeah very easily if your well up on php functions, I can install contributions and shoehorn them into my code but what you said is gobbldygook to me I'm afraid :blink: Since nobody else is answering you and I'm afraid you'll keep posting it or bumping it here is you answer: YES it can be done and very easily. You use the function tep_get_category_tree() which will return the complete tree and only differentiates nested categories by a space (1 space for each nest). You will need to capture the array then strip the entries more than 2 nests. After you've filtered the category array that is returned from the function then pass that into the tep_draw_pull_down_menu() function. Bobby <{POST_SNAPBACK}>
Guest Posted January 21, 2005 Posted January 21, 2005 Was hoping for a more of an idiots guide :'( find line blah blah blah in something.php Replace with blah blah blah :blink:
Recommended Posts
Archived
This topic is now archived and is closed to further replies.