ECSHOPv2.7.2如何在首页商品列表调用该商品所属分类名称

高速度 主机小编为大家介绍下ecshopv2.7.2如何在首页循环调用新品、精品、热销的商品列表,同时调用该商品的所属于的那个分类,点击这个分类,可以链接到该分类。所用ecshop版本为v2.7.2 RELEASE 20100604,修改方法如下:在文件includes/lib_goods.php约289行修改成如下://取出所有符合条件的商品数据,并将结果存入对应的推荐类型数组中$sql='SELECT g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, '."IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, "."promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, g.goods_img, RAND() AS rnd, ". // 分隔字段,连接语句"c.cat_id, c.cat_name ".// 第1处,查询分类ID和名称'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 ".// 第2处,连接分类数据表"ON g.cat_id = c.cat_id ";// 第3处,通过ID找到分类在该php文件约332行加入如下几句:$goods[$idx]['url']=build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);$goods[$idx]['cat_name']=$row['cat_name'];// 第4处,处理分类名称$goods[$idx]['cat_url']=build_uri('category', array('cid' => $row['cat_id']), $row['cat_name']);// 第5处,处理分类链接地址修改完以上五处,假如我们想调用新品,在dwt模板themes/default/index.dwt中调用时就可以这样:<!--{foreach from=$new_goods item=goods}--><div><p><a href="{$goods.url}"><img src="{$goods.thumb}" alt="{$goods.name"escape:html}"></a></p><p><a href="{$goods.cat_url}">{$goods.cat_name}</a></p><p><a href="{$goods.url}" title="{$goods.name"escape:html}">{$goods.short_style_name}</a></p><p>价格:<span class="red">{$goods.shop_price}</span></p></div><!--{/foreach}-->OK,到这就差不多完成了。

本文地址:https://www.gaosudu.com/ecshop/15401.html