百分百源码网-让建站变得如此简单! 登录 注册 签到领金币!

主页 | 如何升级VIP | TAG标签

当前位置: 主页>网站教程>Ecshop教程> ECSHOP商品页_将上一个下一个的ALT改为商品名称
分享本文到:

ECSHOP商品页_将上一个下一个的ALT改为商品名称

发布时间:12/03 来源: 浏览: 关键词:

第1步:修改 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);//下一个商品
        }


第2步: 修改模板文件  (以官方默认模板为例)  /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>

 

责任编辑:
打赏

打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

百分百源码网 建议打赏1~10元,土豪随意,感谢您的阅读!

相关文章

共有17人阅读,期待你的评论!发表评论
昵称: 网址: 验证码: 点击我更换图片
最新评论

本文标签

广告赞助

订阅获得更多模板