在产品详细页面,可以通过点上一页和下一页来实现产品的翻页,在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>
好,到这一步就大功告成了,刷新一下看看是不是变成商品名称了。
|