ecshop产品详细页用产品名称替代图片上下翻页

2009-06-11 22:32 来源:www.chinab4c.com 作者:admin

      在产品详细页面,可以通过点上一页和下一页来实现产品的翻页,在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 class="clearfix">
      <p class="f_l">{$goods.goods_style_name}</p>
      <p class="f_r">
      {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>

  来源:中国B4C电子商务