function smn_show_store_category($store_counter) { global $stree, $boxContent, $sPath_array; for ($i = 0; $i < $stree[$store_counter]['level']; $i++) { $boxContent .= " "; } $boxContent .= '<a href="'; if ($stree[$store_counter]['parent'] == 0) { $sPath_new = 'sPath=' . $store_counter; } else { $sPath_new = 'sPath=' . $stree[$store_counter]['path']; } $boxContent .= smn_href_link(FILENAME_STORE_LISTING, $sPath_new) . '">'; if (isset($sPath_array) && in_array($store_counter, $sPath_array)) { $boxContent .= '<b>'; } // display category name $boxContent .= $stree[$store_counter]['name']; if (isset($sPath_array) && in_array($store_counter, $sPath_array)) { $boxContent .= '</b>'; } if (smn_has_store_category_subcategories($store_counter)) { $boxContent .= '->'; } $boxContent .= '</a>'; if (SHOW_COUNTS == 'true') { $store_in_category = smn_count_store_in_category($store_counter); if ($store_in_category > 0) { $boxContent .= ' (' . $store_in_category . ')'; } } $boxContent .= '<br>'; if ($stree[$store_counter]['next_id'] != false) { smn_show_store_category($stree[$store_counter]['next_id']); } }
function smn_count_store_in_category($store_category_id, $include_inactive = false) { $store_count = 0; if ($include_inactive == true) { $store_query = smn_db_query("select count(*) as total from " . TABLE_STORE_MAIN . " p, " . TABLE_STORE_TO_CATEGORIES . " p2c where p.store_id = p2c.store_id and p2c.store_categories_id = '" . (int) $store_category_id . "'"); } else { $store_query = smn_db_query("select count(*) as total from " . TABLE_STORE_MAIN . " p, " . TABLE_STORE_TO_CATEGORIES . " p2c where p.store_id = p2c.store_id and p.store_status = '1' and p2c.store_categories_id = '" . (int) $store_category_id . "'"); } $store = smn_db_fetch_array($store_query); $store_count += $store['total']; $child_store_categories_query = smn_db_query("select store_categories_id from " . TABLE_STORE_CATEGORIES . " where store_parent_id = '" . (int) $store_category_id . "'"); if (smn_db_num_rows($child_store_categories_query)) { while ($child_store_categories = smn_db_fetch_array($child_store_categories_query)) { $store_count += smn_count_store_in_category($child_store_categories['store_categories_id'], $include_inactive); } } return $store_count; }