Misteraven Posted June 10, 2003 Posted June 10, 2003 I just installed the "All Categories Dropdown" contribution and though it works, there's an issue I'm having... Each category and subcategory have a unique ID number associated with it. When using osCommerce's default categories.php box to navigate sections, it passes this unique ID number as the category path ID (example: cPath=1) in the URL. Further, if you're in a subcategory of that section, it passes the parent category ID and subcategory ID as a string to make the path ID (example: cPath=1_2) in the URL. I've noticed that the All Categories Dropdown only passes the actual category ID and nothing else. Therefore if you're in a subsection of another category, this is not reflected in the path ID. Example: If the parent category ID is 1, and the subcategory ID is 2, with the All Categories Dropdown contribution the path ID would be: cPath=2 rather than cPath=1_2 The problem with this is that although it navigates you to the correct section, it doesn't reflect the proper cPath string which prevents the subcategory image from displaying (default.php). ----------------- Though I believe I'm understanding the problem, I'm lost as how to correct this. I'm decent with PHP, but I lack the skills to follow what's going on in the code. To be honest, I'm not even sure where the code affecting this actually resides (includes/boxes/allcategoriesdropdown.php or includes/functions/general.php)? Any help would be greatly appreciated. Thanks...
interfaSys Posted June 10, 2003 Posted June 10, 2003 If you're still using a version that relies on tep_get_categories, you should modify it so that the while statement looks like this : while ($categories = tep_db_fetch_array($categories_query)) { //Modification to output the full cPath if ($categories['parent_id']!=0) { $blipblap = $categories['parent_id'] . '_' . $categories['categories_id']; $blipblop = $indent . $categories['categories_name']; }else{ $blipblap = 'nolink'; $blipblop = $indent . '[' . $categories['categories_name'] . ']'; } $categories_array[] = array('id' => $blipblap, 'text' => $blipblop ); This is a quick hack that is quite old, so there is no promise that i'ts standard compliant. I might have to work on this later this month and may release an updated version of the script Olivier interfaSys s?rl ----------------------- You'll love to use our solutions! Rich Internet Applications and Usability
Misteraven Posted June 10, 2003 Author Posted June 10, 2003 Weirdlab, Thanks for the response. I tried your suggestion and got a slew of errors, so I'm not sure I'm following your advice correctly. (I'm using version: v 1.102 2002/11/02 03:06:05) Here's the relevant snippet out of my general.php $categories_query = tep_db_query("select c.categories_id, cd.categories_name from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where parent_id = '" . tep_db_input($parent_id) . "' and c.categories_id = cd.categories_id and cd.language_id = '" . $languages_id . "' order by sort_order, cd.categories_name"); while ($categories = tep_db_fetch_array($categories_query)) { $categories_array[] = array('id' => $categories['categories_id'], 'text' => $indent . $categories['categories_name']); if ($categories['categories_id'] != $parent_id) { $categories_array = tep_get_categories($categories_array, $categories['categories_id'], $indent . ' '); } } return $categories_array; } [/code]
interfaSys Posted June 11, 2003 Posted June 11, 2003 You probably didn't add the parent_id field in your DB query. Here is the full function, but beware, it's old! function tep_get_categories($categories_array = '', $parent_id = '0', $indent = '') { global $languages_id; $parent_id = tep_db_prepare_input($parent_id); if (!is_array($categories_array)) $categories_array = array(); $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where parent_id = '" . tep_db_input($parent_id) . "' and c.categories_id = cd.categories_id and cd.language_id = '" . $languages_id . "' order by sort_order, cd.categories_name"); while ($categories = tep_db_fetch_array($categories_query)) { //Modification to output the full cPath if ($categories['parent_id']!=0) { $blipblap = $categories['parent_id'] . '_' .$categories['categories_id']; $blipblop = $indent . $categories['categories_name']; }else{ $blipblap = 'nolink'; $blipblop = $indent . '[' . $categories['categories_name'] . ']'; } $categories_array[] = array('id' => $blipblap, 'text' => $blipblop ); if ($categories['categories_id'] != $parent_id) { $categories_array = tep_get_gallery_categories($categories_array, $categories['categories_id'], $indent . ' '); } } return $categories_array; } Olivier interfaSys s?rl ----------------------- You'll love to use our solutions! Rich Internet Applications and Usability
billyjack Posted June 11, 2003 Posted June 11, 2003 Not sure if this is what you are looking for but I found this to work great for my dropdown. Everything else I tried didn't seem to work well and this worked without any modification. http://www.oscommerce.com/community/contributions,46
Misteraven Posted June 11, 2003 Author Posted June 11, 2003 You probably didn't add the parent_id field in your DB query. Here is the full function, but beware, it's old! function tep_get_categories($categories_array = '', $parent_id = '0', $indent = '') { global $languages_id; $parent_id = tep_db_prepare_input($parent_id); if (!is_array($categories_array)) $categories_array = array(); $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where parent_id = '" . tep_db_input($parent_id) . "' and c.categories_id = cd.categories_id and cd.language_id = '" . $languages_id . "' order by sort_order, cd.categories_name"); while ($categories = tep_db_fetch_array($categories_query)) { //Modification to output the full cPath if ($categories['parent_id']!=0) { $blipblap = $categories['parent_id'] . '_' .$categories['categories_id']; $blipblop = $indent . $categories['categories_name']; }else{ $blipblap = 'nolink'; $blipblop = $indent . '[' . $categories['categories_name'] . ']'; } $categories_array[] = array('id' => $blipblap, 'text' => $blipblop ); if ($categories['categories_id'] != $parent_id) { $categories_array = tep_get_gallery_categories($categories_array, $categories['categories_id'], $indent . ' '); } } return $categories_array; } Here's the error i got when I tried your code: Parse error: parse error in /home/www1/fourthehardway.com/htdocs/shop/catalog/includes/functions/general.php on line 486 Fatal error: Call to undefined function: tep_not_null() in /home/www1/fourthehardway.com/htdocs/shop/catalog/includes/functions/html_output.php on line 22 I'm trying to figure out the problem, but like I said earlier, this is pretty much out of my league. Regardless, I appreciate the help. Any ideas what the issue is?
Misteraven Posted June 11, 2003 Author Posted June 11, 2003 Not sure if this is what you are looking for but I found this to work great for my dropdown. Everything else I tried didn't seem to work well and this worked without any modification.http://www.oscommerce.com/community/contributions,46 Though this contribution does work, it has the same flaw in not passing the parent category ID when browsing subcategories. Thus not showing the subcategory graphic.
Misteraven Posted June 11, 2003 Author Posted June 11, 2003 Seems like the first parse error at line 486 is: global $languages_id; However, I'm not sure I'm seeing the problem?
Misteraven Posted June 11, 2003 Author Posted June 11, 2003 actually disregard that last post, the problem is somthing else.
Misteraven Posted June 11, 2003 Author Posted June 11, 2003 Alright, I'm going through this little by little and the issue seems to be with the first line of the modified code: ? ? ? if ($categories['parent_id']!=0) { ? ? ? ? ? $blipblap = $categories['parent_id'] . '_' .$categories['categories_id']; Also, I'm still clueless as to the second error: Fatal error: Call to undefined function: tep_not_null() in /home/www1/fourthehardway.com/htdocs/shop/catalog/includes/functions/html_output.php on line 22
Misteraven Posted June 18, 2003 Author Posted June 18, 2003 I'm still stuck. has anyone encountered, or better yet, solved this issue? please help.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.