您现在的位置是:首页 > 教程 > ecshop商城教程ecshop商城教程
ecshop商品页面增加上一个商品下一个商品商品名称
凌瑛昼2024-04-25 20:54:16ecshop商城教程已有人查阅
导读ecshop商品页面增加上一个商品下一个商品商品名称,第一步:修改 goods.php 文件找到下面这段代码
ecshop商品页面增加上一个商品下一个商品商品名称。
第一步:修改 goods.php 文件
找到下面这段代码
将
第一步:修改 goods.php 文件
找到下面这段代码
/* 上一个商品下一个商品 */
$prev_gid = $db->getOne("SELECT 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 LIMIT 1");
if (!empty($prev_gid))
{
$prev_good['url'] = build_uri('goods', array('gid' => $prev_gid), $goods['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), $goods['goods_name']);
$smarty->assign('next_good', $next_good);//下一个商品
}
然后将它修改为下面代码(注意红 部分)
/* 上一个商品下一个商品 */
$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']), $goods['goods_name']);
$prev_good['goods_name'] =$prev_gid['goods_name'];
$smarty->assign('prev_good', $prev_good);//上一个商品
}
$next_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 order by goods_id desc limit 1");
if (!empty($next_gid))
{
$next_good['url'] = build_uri('goods', array('gid' => $next_gid['goods_id']), $goods['goods_name']);
$next_good['goods_name'] =$next_gid['goods_name'];
$smarty->assign('next_good', $next_good);//下一个商品
}
第二步: 修改模板文件 (以官方默认模板为例) /themes/default/goods.dwt将
<a href="{$prev_good.url}"><img alt="prev" src="./images/up.gif" /></a>
修改为:
<a href="{$prev_good.url}"><img alt="{$prev_good.goods_name}" src="./images/up.gif" /></a>
再将
<a href="{$next_good.url}"><img alt="next" src="./images/down.gif" /></a>
修改为
<a href="{$next_good.url}"><img alt="{$next_good.goods_name}" src="./images/down.gif" /></a>
本文标签:
很赞哦! ()
相关文章
随机图文
-
ecshop二次开发必备知识
近年来,随着互联网的发展,电子商务也跟着一起成长,B2B,C2C,B2C的电子商务模式也不断的成熟。这时催生出了众多电子商务相关的PHP开源产品。B2C方面有Ecshop,Zencart,Magento等国内外知名产品。 -
ecshop首页热门搜索关键词怎么实现随机显示
1、打开 include/lib_main.php 文件,找到下面这段代码,删除之(大概在1652行左右)2 、打开 include/lib_insert.php 文件 ,在文件最下边加入下面这个函数 -
ecshop的title标签优化方法
刚用ecshop新做了个商城,收集了不少title优化,分享下网站首页标题显示的是为ECSHOP管理中心的[商店标题]。而频道页面,显示的是[频道名+商店名称]。 -
ecshop订单列表增加商品检索的方法
近期ecshop网站做活动,统计商品订单量的时候没有按商品名搜索的选项,只能手动查询。这样效率很低下,而且容易出错。现在为列表增加一个简单的“按商品名搜索”表单项。
留言与评论 (共有 条评论) |