ecshop产品详细页用产品名称替代图片上下翻页

更新时间:2012-08-07 点击量:2103

在产品详细页面,可以通过点上一页和下一页来实现产品的翻页,在ec的论坛中,很多朋友都希望把这个功能修改,将上一页和下一页的图片换成产品名称,晚上回家后看了看,其实也不难.

在goods.php程序中,修改成下面这样.

/* 上一个商品下一个商品 */
$prev_gid = $db->getRow("SELECT goods_id,goods_name FROM " .$ecs->table('goods'). " WHERE cat_id=" . $goods['cat_id'] . " AND goods_id > " . $goods['goods_id'] . " AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0 LIMIT 1");

if (!empty($prev_gid))
{
$prev_good['url'] = build_uri('goods', array('gid' => $prev_gid['goods_id']));
$prev_good['goods_name'] = $prev_gid['goods_name'];

$smarty->assign('prev_good', $prev_good);//上一个商品
}

$next_gid = $db->getOne("SELECT max(goods_id)  FROM " . $ecs->table('goods') . " WHERE cat_id=".$goods['cat_id']." AND goods_id < ".$goods['goods_id'] . " AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0");
if (!empty($next_gid))
{
$next_good['url'] = build_uri('goods', array('gid' => $next_gid));
if($next_gid){
$next_good['goods_name'] = $db -> getOne("select goods_name from ".$ecs->table('goods')." where goods_id =".$next_gid);//下一个商品}
}
$smarty->assign('next_good', $next_good);
}

用产品名称代替图片$prev_gid['goods_name'],$next_good['goods_name'] = $db -> getOne("select goods_name from ".$ecs->table('goods')." where goods_id =".$next_gid);

ecshop模板文件中.找到goods.dwt,修改成下面小代码

<div>
<p>{$goods.goods_style_name}</p>
<p>
{if $prev_good}
<a href="{$prev_good.url}">{$prev_good.goods_name}</a>
{/if}
{if $next_good}
<a href="{$next_good.url}">{$next_good.goods_name}</a>
{/if}
</p>
</div>

好,到这一步就大功告成了,刷新一下看看是不是变成商品名称了。

 

支付宝扫码打赏 微信打赏

如果文章对您有帮助,就打赏一个吧

在线客服

客户服务

热线电话:

0755-36656507 15889489919 服务时间:

周一到周六:9:00-18:00

在线QQ客服

在线微信客服

关于我们 常见问题

支付方式 加盟合作

提交需求
优惠红包 购物车0 反馈留言 返回顶部