博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ECSHOP商品页_将上一个下一个图片改为商品名称
阅读量:6232 次
发布时间:2019-06-21

本文共 2121 字,大约阅读时间需要 7 分钟。

hot3.png

第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}">{$prev_good.goods_name}"</a>

再将

<a href="{$next_good.url}"><img alt="next" src="./images/down.gif" /></a>

修改为

<a href="{$next_good.url}">{$next_good.goods_name}"</a>

转载于:https://my.oschina.net/Android1989/blog/298154

你可能感兴趣的文章
谈谈JDK线程的伪唤醒
查看>>
ORA-39901 EXPDP分区报错/分区表删除不完全
查看>>
HDU 4946 共线凸包
查看>>
图片轮播插件 Slides-SlidesJS-3
查看>>
让python 3支持mysqldb的解决方法
查看>>
JAVA与.NET的相互调用——TCP/IP相互调“.NET研究”用基本架构
查看>>
一起谈.NET技术,打包Asp.Net 网站成为一个exe方便快捷的进行客户演示
查看>>
[转]Android中设置TextView的颜色setTextColor
查看>>
随手记一 2018/04/23 Ajax基础了解
查看>>
C++ C# python 中输入输出函数对比
查看>>
Java 入门
查看>>
test4 结对项目
查看>>
idea老版本下载
查看>>
SQL SERVER 2008 多边形问题的解决
查看>>
RTEMS进程同步机制
查看>>
关于访问MSMQ远端私有队列的一点经验
查看>>
前端表单校验插件 jquery.validate.min.js自定义校验规则
查看>>
MySQL系列:高可用架构之MHA
查看>>
python堡垒机开发
查看>>
共享内存
查看>>