コード例 #1
0
ファイル: lib_goods.php プロジェクト: dw250100785/ECShop-1
function get_child_tree($tree_id = 0)
{
    $three_arr = array();
    $sql = 'SELECT count(*) FROM ' . $GLOBALS['ecs']->table('category') . " WHERE parent_id = '{$tree_id}' AND is_show = 1 ";
    if ($GLOBALS['db']->getOne($sql) || $tree_id == 0) {
        $child_sql = 'SELECT cat_id, cat_name, parent_id, is_show ' . 'FROM ' . $GLOBALS['ecs']->table('category') . "WHERE parent_id = '{$tree_id}' AND is_show = 1 ORDER BY sort_order ASC, cat_id ASC";
        $res = $GLOBALS['db']->getAll($child_sql);
        foreach ($res as $row) {
            if ($row['is_show']) {
                $three_arr[$row['cat_id']]['id'] = $row['cat_id'];
            }
            $three_arr[$row['cat_id']]['name'] = $row['cat_name'];
            $three_arr[$row['cat_id']]['url'] = build_uri('category', array('cid' => $row['cat_id']), $row['cat_name']);
            if (isset($row['cat_id']) != NULL) {
                $three_arr[$row['cat_id']]['cat_id'] = get_child_tree($row['cat_id']);
            }
        }
    }
    return $three_arr;
}
コード例 #2
0
ファイル: index.php プロジェクト: xiaoxiaowu007/jicai
	
    $smarty->assign('helps',           get_shop_help());       // 网店帮助
    $smarty->assign('top_goods',       get_top10());           // 销售排行
	
	
	//获取首页的设计师和技工
	$smarty->assign('jg',      get_sjs_info('jg'));
	$smarty->assign('sjs',     get_sjs_info('sjs'));

	
	//指定分类区域
	$smarty->assign('categories1',      get_child_tree(1));  //f1
	$smarty->assign('categories2',      get_child_tree(2));  //f1
	$smarty->assign('categories3',      get_child_tree(3));  //f1
	$smarty->assign('categories4',      get_child_tree(4));  //f1
	$smarty->assign('categories5',      get_child_tree(5));  //f1
	

   // $smarty->assign('best_goods',      get_recommend_goods('best'));    // 推荐商品
   // $smarty->assign('new_goods',       get_recommend_goods('new'));     // 最新商品
   // $smarty->assign('hot_goods',       get_recommend_goods('hot'));     // 热点文章
   // $smarty->assign('promotion_goods', get_promote_goods()); // 特价商品
    $smarty->assign('brand_list',      get_brands());
    $smarty->assign('promotion_info',  get_promotion_info()); // 增加一个动态显示所有促销信息的标签栏
	
	
	/*$smarty->assign('hot_goods1',       get_recommend_goods('hot',"1"));
	$smarty->assign('hot_goods2',       get_recommend_goods1('hot',"2"));
	$smarty->assign('hot_goods3',       get_recommend_goods2('hot',"3"));
	$smarty->assign('hot_goods4',       get_recommend_goods3('hot',"4"));
	$smarty->assign('hot_goods5',       get_recommend_goods4('hot',"5"));*/
コード例 #3
0
ファイル: goods1.php プロジェクト: xiaoxiaowu007/jicai
    $smarty->assign('cfg',          $_CFG);
    $smarty->assign('promotion',       get_promotion_info($goods_id));//促销信息
    $smarty->assign('promotion_info', get_promotion_info());

    /* 获得商品的信息 */
    $goods = get_goods_info($goods_id);


	$cat_id = $goods['cat_id'];
	
	//根据楼层id 选出所有的子集id
	$louceng_qq=explode(',',$_CFG['skype']);
	
	$id1 = get_child_tree(705);
	$id2 = get_child_tree(706);
	$id3 = get_child_tree(707);


	//假设产品就在市场这个分类下
	$cat_sql ="select parent_id,kfqq from ecs_category  where cat_id =".$cat_id;
	
	$mes = $db->getAll($cat_sql);
	
	
	
	//判断客服qq是否直接在本身的栏目中
	if(!$mes[0]['kfqq']){
		
		//如果不在,则根据父级栏目id找寻上一级
		$cat_sql1 ="select parent_id,kfqq from ecs_category  where cat_id =".$mes[0]['parent_id'];
	
コード例 #4
0
ファイル: function.php プロジェクト: hello7921/haorizi
function get_cate_tree($mod, $id = 0)
{
    $where = array();
    if ($id > 0) {
        $where['id'] = $id;
    } else {
        $where['pid'] = 0;
    }
    $list = $mod->where($where)->select();
    foreach ($list as $key => $val) {
        $list[$key]['depth'] = 0;
        $list[$key]['child'] = get_child_tree($mod, $val['id'], 0);
    }
    return $list;
}
コード例 #5
0
ファイル: lib_goods.php プロジェクト: jinjing1989/wei
/**
 * 获得指定分类下的商品
 *
 * @access  public
 * @param   integer     $cat_id     分类ID
 * @param   integer     $num        数量
 * @param   string      $from       来自web/wap的调用
 * @param   string      $order_rule 指定商品排序规则
 * @return  array
 */
function assign_cat_goods($cat_id, $num = 0, $from = 'web', $order_rule = '')
{
    $children = get_children($cat_id);
    $sql = 'SELECT g.goods_id, g.goods_name, g.market_price, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, " . 'g.promote_price, promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, g.goods_img ' . "FROM " . $GLOBALS['ecs']->table('goods') . ' AS g ' . "LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . 'WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND ' . 'g.is_delete = 0 AND (' . $children . 'OR ' . get_extension_goods($children) . ') ';
    $order_rule = empty($order_rule) ? 'ORDER BY g.sort_order, g.goods_id DESC' : $order_rule;
    $sql .= $order_rule;
    if ($num > 0) {
        $sql .= ' LIMIT ' . $num;
    }
    $res = $GLOBALS['db']->getAll($sql);
    $goods = array();
    foreach ($res as $idx => $row) {
        if ($row['promote_price'] > 0) {
            $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
            $goods[$idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : '';
        } else {
            $goods[$idx]['promote_price'] = '';
        }
        $goods[$idx]['id'] = $row['goods_id'];
        $goods[$idx]['name'] = $row['goods_name'];
        $goods[$idx]['brief'] = $row['goods_brief'];
        $goods[$idx]['market_price'] = price_format($row['market_price']);
        $goods[$idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
        $goods[$idx]['shop_price'] = price_format($row['shop_price']);
        $goods[$idx]['thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
        $goods[$idx]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
        $goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
    }
    if ($from == 'web') {
        $GLOBALS['smarty']->assign('cat_goods_' . $cat_id, $goods);
    } elseif ($from == 'wap') {
        $cat['goods'] = $goods;
    }
    /* 分类信息 */
    $sql = 'SELECT cat_name FROM ' . $GLOBALS['ecs']->table('category') . " WHERE cat_id = '{$cat_id}'";
    $cat['name'] = $GLOBALS['db']->getOne($sql);
    $cat['url'] = build_uri('category', array('cid' => $cat_id), $cat['name']);
    $cat['id'] = $cat_id;
    $cat['cat_id'] = get_child_tree($cat_id);
    //增加子类别调用 by Bragg
    return $cat;
}
コード例 #6
0
ファイル: lib_goods_bak.php プロジェクト: norain2050/benhu
function get_child_tree_goods($tree_id = 0)
{
    $three_arr = array();
    $sql = 'SELECT count(*) FROM ' . $GLOBALS['ecs']->table('category') . " WHERE parent_id = '{$tree_id}' AND is_show = 1 ";
    if ($GLOBALS['db']->getOne($sql) || $tree_id == 0) {
        $child_sql = 'SELECT cat_id, cat_name, parent_id, is_show ' . 'FROM ' . $GLOBALS['ecs']->table('category') . "WHERE parent_id = '{$tree_id}' AND is_show = 1 ORDER BY sort_order ASC, cat_id ASC LIMIT 7";
        $res = $GLOBALS['db']->getAll($child_sql);
        foreach ($res as $row) {
            if ($row['is_show']) {
                $three_arr[$row['cat_id']]['id'] = $row['cat_id'];
            }
            $three_arr[$row['cat_id']]['name'] = $row['cat_name'];
            $three_arr[$row['cat_id']]['url'] = build_uri('category', array('cid' => $row['cat_id']), $row['cat_name']);
            $children = get_children($row['cat_id']);
            $sql = 'SELECT g.goods_id,g.cat_id, g.goods_name, g.market_price, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, " . 'g.promote_price, promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, g.goods_img ' . "FROM " . $GLOBALS['ecs']->table('goods') . ' AS g ' . "LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . 'WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND ' . 'g.is_delete = 0 AND (' . $children . 'OR ' . get_extension_goods($children) . ')  ORDER BY g.sort_order, g.goods_id DESC';
            $goods_res = $GLOBALS['db']->getAll($sql);
            $goods = array();
            foreach ($goods_res as $idx => $row) {
                if ($row['promote_price'] > 0) {
                    $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
                    $goods[$idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : '';
                } else {
                    $goods[$idx]['promote_price'] = '';
                }
                $goods[$idx]['id'] = $row['goods_id'];
                $goods[$idx]['name'] = $row['goods_name'];
                $goods[$idx]['brief'] = $row['goods_brief'];
                $goods[$idx]['market_price'] = $row['market_price'];
                $goods[$idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
                $goods[$idx]['shop_price'] = price_format($row['shop_price']);
                $goods[$idx]['thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
                $goods[$idx]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
                $goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
            }
            $three_arr[$row['cat_id']]['goods'] = $goods;
            if (isset($row['cat_id']) != NULL) {
                $three_arr[$row['cat_id']]['cat_id'] = get_child_tree($row['cat_id']);
            }
        }
    }
    return $three_arr;
}
コード例 #7
0
ファイル: lib_main.php プロジェクト: GYWang1983/fruit
function get_categories_tree_xaphp($cat_id = 0)
{
    if ($cat_id > 0) {
        $sql = 'SELECT parent_id FROM ' . $GLOBALS['ecs']->table('category') . " WHERE cat_id = '{$cat_id}'";
        $parent_id = $GLOBALS['db']->getOne($sql);
    } else {
        $parent_id = 0;
    }
    /*
     判断当前分类中全是是否是底级分类,
     如果是取出底级分类上级分类,
     如果不是取当前分类及其下的子分类
    */
    $sql = 'SELECT count(*) FROM ' . $GLOBALS['ecs']->table('category') . " WHERE parent_id = '{$cat_id}' AND is_show = 1 ";
    /* 获取当前分类及其子分类 */
    $sql = 'SELECT cat_id,cat_name ,parent_id,is_show ' . 'FROM ' . $GLOBALS['ecs']->table('category') . "WHERE parent_id = '{$cat_id}' AND is_show = 1 ORDER BY sort_order ASC, cat_id ASC";
    $res = $GLOBALS['db']->getAll($sql);
    foreach ($res as $row) {
        if ($row['is_show']) {
            $cat_arr[$row['cat_id']]['id'] = $row['cat_id'];
            $cat_arr[$row['cat_id']]['name'] = $row['cat_name'];
            $cat_arr[$row['cat_id']]['url'] = build_uri('category', array('cid' => $row['cat_id']), $row['cat_name']);
            if (isset($row['cat_id']) != NULL) {
                $cat_arr[$row['cat_id']]['cat_id'] = get_child_tree($row['cat_id']);
            }
        }
    }
    if (isset($cat_arr)) {
        return $cat_arr;
    }
}
コード例 #8
0
ファイル: category.php プロジェクト: muqidi/PHP
         foreach ($filter_attr as $k => $v) {
             if (is_numeric($v) && $v != 0 && isset($cat_filter_attr[$k])) {
                 $sql = $ext_sql . "b.attr_value = a.attr_value AND b.attr_id = " . $cat_filter_attr[$k] . " AND a.goods_attr_id = " . $v;
                 $ext_group_goods = $db->getColCached($sql);
                 $ext .= ' AND ' . db_create_in($ext_group_goods, 'g.goods_id');
             }
         }
     }
 }
 assign_template('c', array($cat_id));
 $position = assign_ur_here($cat_id, $brand_name);
 $smarty->assign('page_title', $position['title']);
 // 页面标题
 $smarty->assign('ur_here', $position['ur_here']);
 // 当前位置
 $smarty->assign('categories', get_child_tree($cat_id));
 // 分类树
 $smarty->assign('helps', get_shop_help());
 // 网店帮助
 $smarty->assign('top_goods', get_top10());
 // 销售排行
 $smarty->assign('show_marketprice', $_CFG['show_marketprice']);
 $smarty->assign('category', $cat_id);
 $smarty->assign('brand_id', $brand);
 $smarty->assign('price_max', $price_max);
 $smarty->assign('price_min', $price_min);
 $smarty->assign('filter_attr', $filter_attr_str);
 $smarty->assign('feed_url', $_CFG['rewrite'] == 1 ? "feed-c{$cat_id}.xml" : 'feed.php?cat=' . $cat_id);
 // RSS URL
 if ($brand > 0) {
     $arr['all'] = array('brand_id' => 0, 'brand_name' => $GLOBALS['_LANG']['all_goods'], 'brand_logo' => '', 'goods_num' => '', 'url' => build_uri('category', array('cid' => $cat_id), $cat['cat_name']));
コード例 #9
0
ファイル: common.php プロジェクト: kid2682/SMZDM
function get_child_tree($mod, $pid, $depth = 0)
{
    $where['pid'] = $pid;
    $list = $mod->where($where)->select();
    if ($list) {
        $depth++;
        foreach ($list as $key => $val) {
            $list[$key]['depth'] = $depth;
            $list[$key]['child'] = get_child_tree($mod, $val['id'], $depth);
        }
    } else {
        return false;
    }
    return $list;
}