ecshop中如何在分类列表中调用商品同一级分类的名称

 我来答
qq40499756
2012-02-23 · 超过44用户采纳过TA的回答
知道答主
回答量:98
采纳率:0%
帮助的人:147万
展开全部
在category.php中的category_get_goods函数的
/* 获得商品列表 */
$sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, title_adwords, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ' .
"IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, g.promote_price, g.goods_type, " .
'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img, g.click_count as click_count ';
$sql .= $sort =='sale_number'? ', SUM(og.goods_number) as sale_number ':'';
$sql .='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]' " ;
改成

/* 获得商品列表 */
$sql = 'SELECT g.goods_id, g.cat_id,c.cat_name, g.goods_name, g.goods_name_style, title_adwords, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ' .
"IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, g.promote_price, g.goods_type, " .
'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img, g.click_count as click_count ';
$sql .= $sort =='sale_number'? ', SUM(og.goods_number) as sale_number ':'';
$sql .='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]' " .
'LEFT JOIN ' . $GLOBALS['ecs']->table(category') . ' AS c on c.cat_id =g.cat_id ' ;


$arr[$row['goods_id']]['name'] = $row['goods_name'];
下面增加
$arr[$row['goods_id']]['cat_name'] = $row['cat_name'];
然后在模板里就可以在模板中通过{goods.cat_name}直接调用
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式