码迷,mamicode.com
首页 > 其他好文 > 详细

ECSHOP教程之商品页_将上一个下一个图片改为商品名称

时间:2015-08-30 14:14:45      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:

第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>

 

ECSHOP教程之商品页_将上一个下一个图片改为商品名称

标签:

原文地址:http://www.cnblogs.com/yundu/p/4770775.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!