最模板 - 外贸网站建设,外贸网站模板

最模板

当前位置: 首页 > 建站教程 > CMS教程 > ECShop教程 >

如何在ecshop产品详细页用产品名称替代图片上下

时间:2014-06-10 11:03来源: 作者: 点击:
在产品详细页面,可以通过点上一页和下一页来实现产品的翻页,在 ec 的论坛中,很多朋友都希望把这个功能修改,将上一页和下一页的图片换成产品名称,晚上回家后看了看,其实也
(责任编辑:admin)

 

在产品详细页面,可以通过点上一页和下一页来实现产品的翻页,在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>

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

 

------分隔线----------------------------
栏目列表
推荐内容