Guest Posted January 20, 2007 Share Posted January 20, 2007 Hey all, I have been racking my brain on this for too long and I need some help. I searched the forums up and down and most people that asked this question didn't get a response. The problem is that I have a few sub-categories that have the same name. Something like: Category1 Sub-category1 This That Other Category2 Sub-category1 This That Other Sub-category1 This That Other Category3 Sub-category1 Sub-category2 When I select a manufacturer, the categories dropdown looks like: Category1 Sub-category1 This That Other Category2 Sub-category1 This That Other Sub-category1 This That Other Category3 Sub-category1 Sub-category2 It's pretty confusing for people that aren't familiar with our entire category layout. I'm looking for a contrib or help making one that will do something like: Dropdown1 Category1 Category2 When Category2 is selected a 2nd dropdown is displayed or filled Dropdown2 Sub-category1 Sub-category2 When Sub-category2 is selected a 3rd dropdown is displayed or filled Dropdown3 This That Other It's hard to explain and I don't have an example URL on hand, I'll try to find one. But basically I need a dropdown for each level (I have 3 levels max, some only 2). On index.php below the line "if (PRODUCT_LIST_FILTER > 0) {" it uses the same syntax for the categories and manufacturers dropdowns. I split them so I could make changes to the categories dropdown only. But unfortunately I'm no guru at sql, yet anyways ;P I was messing around with a contrib called "Hieracrcical Categories" but it only displays 2 levels deep and in a single dropdown. Then I got the contrib called "Main categories in front page". I thought I might be able to use it because it can display the categories, sub-categories, and sub-categories children as text links. But I'm having trouble with the sql query. Original SQL quesry from index.php categories/manufacturer dropdown: $filterlist_sql = "select distinct c.categories_id as id, cd.categories_name as name, c.parent_id as parent_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where p.products_status = '1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and p2c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' order by c.parent_id, c.sort_order, cd.categories_name"; SQL for main categories looks like: $query = "select c.categories_id, cd.categories_name, c.parent_id, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id"; // 1.3 Can't have 'where' in an if statement! if ($status >0) $query.= " and c.status = '1'"; $query.= " and cd.language_id='" . $languages_id ."' order by sort_order, cd.categories_name"; If I can get the sql query right I'm sure I can do the rest, but I don't know enough about SQL, patriotically how it determines only to display categories for a particular manufacturer. Thanks in advance Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.