function get_goods_count($cat_id, $time = NULL) { $subcat_list = get_subcat_list($cat_id); $count = 0; if ($subcat_list) { foreach ($subcat_list as $cat) { $model_goods = app::get('b2c')->model('goods'); $filter = array("cat_id" => $cat['cat_id']); if ($time) { $filter += array('uptime|bthan' => $time); } $count += $model_goods->count($filter); } } $model_goods = app::get('b2c')->model('goods'); $filter = array("cat_id" => $cat_id); if ($time) { $filter += array('uptime|bthan' => $time); } $count += $model_goods->count($filter); return $count; }
<?php $GLOBALS['smarty']->assign('top_cat_name1', $GLOBALS['cat']['cat_name'] . "频道"); $GLOBALS['smarty']->assign('top_cat_name2', $GLOBALS['cat']['cat_name']); $GLOBALS['smarty']->assign('cat_id', $GLOBALS['cat_id']); $GLOBALS['smarty']->assign('topcat_info', get_topcat_info($GLOBALS['cat_id'])); $GLOBALS['smarty']->assign('flash_img_list', get_flash_img($GLOBALS['cat_id'])); $GLOBALS['smarty']->assign('subcat_list', get_subcat_list($GLOBALS['cat_id'])); $children = get_children($GLOBALS['cat_id']); $GLOBALS['smarty']->assign('goods_list_new', get_catindex_recommend_goods('new', $children)); $GLOBALS['smarty']->assign('goods_list_best', get_catindex_recommend_goods('best', $children)); $GLOBALS['smarty']->assign('goods_list_hot', get_catindex_recommend_goods('hot', $children)); $GLOBALS['smarty']->assign('promotion_goods', get_promote_goods($GLOBALS['cat_id'])); $GLOBALS['smarty']->assign('childcat_goods', get_childcat_goods($GLOBALS['cat_id'])); $GLOBALS['smarty']->assign('get_pro_top', get_pro_top10($GLOBALS['cat_id'])); //$GLOBALS['smarty']->display('category_index.dwt',$GLOBALS['cache_id']); function http() { return isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off' ? 'https://' : 'http://'; } function get_domain() { $protocol = http(); if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { $host = $_SERVER['HTTP_X_FORWARDED_HOST']; } elseif (isset($_SERVER['HTTP_HOST'])) { $host = $_SERVER['HTTP_HOST']; } else { if (isset($_SERVER['SERVER_PORT'])) { $port = ':' . $_SERVER['SERVER_PORT']; if (':80' == $port && 'http://' == $protocol || ':443' == $port && 'https://' == $protocol) {
} $category_tree0 = get_categories_tree(0); $smarty->assign('category_tree0', $category_tree0); assign_template('c', array($cat_id)); /*取得顶级ID*/ $catlist = array(); $catsinfo = get_parent_cats($cat_id); foreach ($catsinfo as $k => $v) { $catlist[] = $v['cat_id']; } $smarty->assign('current_cat_pr_id', $catlist[count($catlist) - 1]); /*取得顶级ID*/ $smarty->assign('cat_id', $cat_id); $smarty->assign('topcat_info', get_topcat_info($cat_id)); $smarty->assign('flash_img_list', get_flash_img($cat_id)); $smarty->assign('subcat_list', get_subcat_list($cat_id)); $children = get_children($cat_id); $smarty->assign('goods_list_new', get_catindex_recommend_goods('new', $children)); $smarty->assign('goods_list_best', get_catindex_recommend_goods('best', $children)); $smarty->assign('goods_list_hot', get_catindex_recommend_goods('hot', $children)); $smarty->assign('promotion_goods', get_promote_goods($cat_id)); $smarty->assign('childcat_goods', get_childcat_goods($cat_id)); $smarty->assign('get_pro_top', get_pro_top10($cat_id)); assign_dynamic('category_index'); // 动态内容 } $smarty->display('category_index.dwt', $cache_id); } else { /* 初始化分页信息 */ $page = isset($_REQUEST['page']) && intval($_REQUEST['page']) > 0 ? intval($_REQUEST['page']) : 1; $size = isset($_CFG['page_size']) && intval($_CFG['page_size']) > 0 ? intval($_CFG['page_size']) : 10;