goring_gap Posted December 24, 2004 Posted December 24, 2004 Hello, I want to count the top level categories ONLY. I am using count(tep_get_categories()) to count the number of categories. Does anyone know how to modify the call to tep_get_categories() to give info ONLY on top level categories, because by default it seems to count all categories parent and child alike. Hope this makes sense! Cheers Simon
boxtel Posted December 24, 2004 Posted December 24, 2004 Hello, I want to count the top level categories ONLY. I am using count(tep_get_categories()) to count the number of categories. Does anyone know how to modify the call to tep_get_categories() to give info ONLY on top level categories, because by default it seems to count all categories parent and child alike. Hope this makes sense! Cheers Simon <{POST_SNAPBACK}> function tep_get_categories($categories_array = '', $parent_id = '0', $indent = '') { 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 = 0 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)) { $categories_array[] = array('id' => $categories['categories_id'], 'text' => $indent . $categories['categories_name']); } return $categories_array; } Treasurer MFC
goring_gap Posted January 11, 2005 Author Posted January 11, 2005 function tep_get_categories($categories_array = '', $parent_id = '0', $indent = '') { 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 = 0 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)) { $categories_array[] = array('id' => $categories['categories_id'], 'text' => $indent . $categories['categories_name']); } return $categories_array; } <{POST_SNAPBACK}> thanks
Recommended Posts
Archived
This topic is now archived and is closed to further replies.