'; }else{ require($template->get_template_dir('tpl_shopby_categories.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_shopby_categories.php'); $sql = 'select c.categories_id,cd.categories_name,c.parent_id from '.TABLE_CATEGORIES.' c ,'.TABLE_CATEGORIES_DESCRIPTION.' cd where c.categories_id=cd.categories_id and cd.language_id="'.(int)$_SESSION['languages_id'].'" and c.categories_status="1" order by c.sort_order asc, cd.categories_name asc'; $all_categories = $db->Execute($sql); $counter = 0; $_categories = array(); $_max = 70; $category_id = $_GET['cPath']; $category_id = array_reverse(explode('_', $category_id)); $category_id = $category_id[0]; while (!$all_categories->EOF) { $_categories[] = $all_categories->fields; if($all_categories->fields['categories_id']==$category_id){ $current_category = $all_categories->fields; } $all_categories->MoveNext(); } $current = $current_category; function getParentCategory($_categories,$category){ foreach ($_categories as $_category){ if($_category['categories_id']==$category['parent_id']){ $parent = $_category; break; } } return $parent; } function getChildrenCategory($_categories,$parent_category){ $array = array(); foreach ($_categories as $key=>$_category){ if($_category['parent_id']==$parent_category['categories_id']){ $_category['children'] = getChildrenCategory($_categories, $_category); $_category['count'] = count($_category['children']); $array[] = $_category; unset($_categories[$key]); } } return $array; } $i = 100; $category_path = array(); $category_path[] = $current_category; /* while ($i>0){ if($current_category['parent_id']==0){ break; }else{ $current_category = getParentCategory($_categories, $current_category); $category_path[] = $current_category; } }*/ $current_category['children'] = getChildrenCategory($_categories, $current_category); function getChildrenHtml($category,$ulclass,$cPathArray,$current){ $html = ''; if($category['count']>0){ foreach ($category['children'] as $sub_category){ $paramsArray = $cPathArray; $paramsArray[] = $sub_category['categories_id']; $params = implode('_', $paramsArray); $base_class = ''; $sub_category['categories_name'] .=get_products_nums_by_categories($sub_category['categories_id']) ; if($current['categories_id']==$sub_category['categories_id']){ $base_class = ' active'; } if($sub_category['count']>0){ $html .='
  • '.$sub_category['categories_name'].''.getChildrenHtml($sub_category,'hide',$paramsArray,$current).'
  • '; }else{ $html .='
  • '.$sub_category['categories_name'].'
  • '; } } $html =''; } return $html; } $content = ''; if(count($category_path)>=3){ $category_path = $category_path[1]; }else{ if(count($category_path)==2){ $category_path = $category_path[0]; } } foreach ($current_category['children'] as $sub_category){ $cPathArray = array(); $cPathArray[] = $sub_category['parent_id']; $cPathArray[] = $sub_category['categories_id']; $cPath = implode('_', $cPathArray); $base_class = ''; if($current['categories_id']==$sub_category['categories_id']){ $base_class = ' active'; } $sub_category['categories_name'] .=get_products_nums_by_categories($sub_category['categories_id']) ; if($sub_category['count']>0){ if($category_path['categories_id']==$sub_category['categories_id']){ $extra_class = ' expand'; $param = ''; }else{ $extra_class = ''; //$param = ' hide'; } $content .='
  • '.$sub_category['categories_name'].''.getChildrenHtml($sub_category,$param,$cPathArray,$current).'
  • '; }else{ if($category_path['categories_id']==$sub_category['categories_id']){ $extra_class = ' expand'; $param = ''; }else{ $extra_class = 'nochildren'; //$param = ' hide'; } $content .='
  • '.$sub_category['categories_name'].'
  • '; } } if($content!=''){ $content = '
    '; } $title = $current_category['categories_name']; $left_corner = false; $right_corner = false; $right_arrow = false; $title_link = false; require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default); }