johka Posted September 8, 2006 Posted September 8, 2006 I have installed this contribution "Category Drop Down List" in my shop. http://www.oscommerce.com/community/contributions,46 and it's working fine but it shows also the sub-categories. Any ideas how i should edit the code so that it only displays main categories. <?php /* osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2001 osCommerce Released under the GNU General Public License */ ?> <!-- categories //--> <tr> <td> <?php function tep_get_paths($categories_array = '', $parent_id = '0', $indent = '', $path='') { global $languages_id; if (!is_array($categories_array)) $categories_array = array(); $categories_query = tep_db_query("select c.categories_id, cd.categories_name from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where parent_id = '" . (int)$parent_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name"); while ($categories = tep_db_fetch_array($categories_query)) { if ($parent_id=='0'){ $categories_array[] = array('id' => $categories['categories_id'], 'text' => $indent . $categories['categories_name']); } else{ $categories_array[] = array('id' => $path . $parent_id . '_' .$categories['categories_id'], 'text' => $indent . $categories['categories_name']); } if ($categories['categories_id'] != $parent_id) { $this_path=$path; if ($parent_id != '0') $this_path = $path . $parent_id . '_'; $categories_array = tep_get_paths($categories_array, $categories['categories_id'], $indent . '??', $this_path); } } return $categories_array; } $info_box_contents = array(); $info_box_contents[] = array('align' => 'left', 'text' => BOX_HEADING_CATEGORIES ); new infoBoxHeading($info_box_contents, true, false); $info_box_contents = array(); $info_box_contents[] = array('form' => '<form action="' . tep_href_link(FILENAME_DEFAULT) . '" method="get">' . tep_hide_session_id(), 'align' => 'left', 'text' => tep_draw_pull_down_menu('cPath', tep_get_paths(array(array('id' => '', 'text' => PULL_DOWN_DEFAULT))), $cPath, 'onchange="this.form.submit();"') ); new infoBox($info_box_contents); ?> </td> </tr> <!-- categories_eof //--> I'll buy a virtual beer to anyone who can help with this one....
after8hrs Posted September 10, 2006 Posted September 10, 2006 I think osC 2.2 default setting is it shows only the main product categories. My question is, if that's what you want, why should you install the drop-down display contribution ?
johka Posted September 10, 2006 Author Posted September 10, 2006 I think osC 2.2 default setting is it shows only the main product categories.My question is, if that's what you want, why should you install the drop-down display contribution ? Well, my situation is that I have 12 main categories, which all have 4-20 subcategories, which have some might have up to 200 subcategories. I fixed the menu in a way that it shows 8 main categories (leading brands) and I want a drop-down box under that which shows only all the 12 main categories (including those 8) but not any subcategories. My shop is very heavily modded, so maybe thats why those contributions won't work very well. At the moment I have this: <tr> <td> <?php $info_box_contents = array(); $info_box_contents[] = array('align' => 'left', 'text' => BOX_HEADING_SEARCH ); new infoBoxHeading($info_box_contents, false, false); $hide = tep_hide_session_id(); $info_box_contents = array(); $info_box_contents[] = array('form' => '<form name="quick_find" method="get" action="' . tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false) . '">', 'align' => 'left', 'text' => $hide . '<b>' . BOX_SEARCH_KAIKKIHAKU . '</b></a>' ); if (MAX_MANUFACTURERS_LIST < 2) { $cat_choose = array(array('id' => '', 'text' => BOX_HEADING_CATEGORIES)); } else { $cat_choose = ''; } //// // Below lines changed by Marcel $categories_array = tep_get_categories($cat_choose); for ($i=0; $i<sizeof($categories_array); $i++) { /* tep_get_path_categories($path_categories, $categories_array[$i]['id']); for ($j = sizeof($path_categories) - 1; $j>=0; $j--) { $path = ($path == "") ? $path_categories[$j] : ($path . "_" .. $path_categories[$j]); } $categories_array[$i]['id'] = ($path == "") ? $categories_array[$i]['id'] : ($path . "_" . $categories_array[$i]['id']); */ } $info_box_contents[] = array('form' => '<form action="' . tep_href_link(FILENAME_DEFAULT) . '" method="get">', 'align' => 'left', 'text' => tep_draw_pull_down_menu('cPath', $categories_array,'','onChange="this.form.submit();" size="' . ((sizeof($categories_array) < MAX_MANUFACTURERS_LIST) ? sizeof($categories_array) : MAX_MANUFACTURERS_LIST) . '" style="width:150"') ); new infoBox($info_box_contents); ?> </td> </tr>
Recommended Posts
Archived
This topic is now archived and is closed to further replies.