$smarty->assign('hot_goods', get_category_recommend_goods('hot', $children, $brand, $price_min, $price_max, $ext)); */ $smarty->assign('hot_goods', get_category_hotSale_goods($children)); $count = get_cagtegory_goods_count($children, $brand, $price_min, $price_max, $ext); $max_page = $count > 0 ? ceil($count / $size) : 1; if ($page > $max_page) { $page = $max_page; } $goodslist = category_get_goods($children, $brand, $price_min, $price_max, $ext, $size, $page, $sort, $order); if ($display == 'grid') { if (count($goodslist) % 2 != 0) { $goodslist[] = array(); } } $smarty->assign('goods_list', $goodslist); $smarty->assign('categories2', get_children_tree($cat_id)); $smarty->assign('category', $cat_id); $smarty->assign('script_name', $dwt_name); assign_pager('category', $cat_id, $count, $size, $sort, $order, $page, '', $brand, $price_min, $price_max, $display, $filter_attr_str); // 分页 assign_dynamic($dwt_name); // 动态内容 } $smarty->display($dwt_name . '.dwt', $cache_id); /*------------------------------------------------------ */ //-- PRIVATE FUNCTION /*------------------------------------------------------ */ /** * 获得分类的信息 * * @param integer $cat_id
function get_children_tree($arr, $pid = 0) { $ret = array(); foreach ($arr as &$item) { if ($item['parent_id'] == $pid) { $item['children'] = get_children_tree($arr, $item['id']); $ret[] = $item; } } return $ret; }