wangtengyu
2018-12-07 f459412e0dac4ed94106da043b4c6f8576bfe496
commit | author | age
3e083b 1 <?php
B 2
3 /**
4  *  列出所有分类及品牌
5 */
6
7 define('IN_ECS', true);
8
9 require(dirname(__FILE__) . '/includes/init.php');
10
11 if ((DEBUG_MODE & 2) != 2)
12 {
13     $smarty->caching = true;
14 }
15
16 if (!$smarty->is_cached('catalog.dwt'))
17 {
18     /* 取出所有分类 */
19     $cat_list = cat_list(0, 0, false);
20
21     foreach ($cat_list AS $key=>$val)
22     {
23         if ($val['is_show'] == 0)
24         {
25             unset($cat_list[$key]);
26         }
27     }
28
29
30     assign_template();
31     assign_dynamic('catalog');
32     $position = assign_ur_here(0, $_LANG['catalog']);
33     $smarty->assign('page_title', $position['title']);   // 页面标题
34     $smarty->assign('ur_here',    $position['ur_here']); // 当前位置
35     $smarty->assign('categories',      get_categories_tree()); // 分类树
36     $smarty->assign('helps',      get_shop_help()); // 网店帮助
37     $smarty->assign('cat_list',   $cat_list);       // 分类列表
38     $smarty->assign('brand_list', get_brands());    // 所以品牌赋值
39     $smarty->assign('promotion_info', get_promotion_info());
40 }
41
42 $smarty->display('catalog.dwt');
43
44 /**
45  * 计算指定分类的商品数量
46  *
47  * @access public
48  * @param   integer     $cat_id
49  *
50  * @return void
51  */
52 function calculate_goods_num($cat_list, $cat_id)
53 {
54     $goods_num = 0;
55
56     foreach ($cat_list AS $cat)
57     {
58         if ($cat['parent_id'] == $cat_id && !empty($cat['goods_num']))
59         {
60             $goods_num += $cat['goods_num'];
61         }
62     }
63
64     return $goods_num;
65 }
66
67 ?>