ecshop商品象册路径的url重写

2010-09-15 20:43 来源:www.chinab4c.com 作者:admin

          ecshop商品象册路径的url重写,这个是一个朋友要我帮他做的。他很细心。发现ecshop伪静态开启后。还是有很多页面没有真正的静态化.比如ecshop商品页面的商品象册地址.

1:规则
RewriteRule ^(.*)/gallery-([0-9]+)-img([0-9]+)\.html$                        $1/gallery\.php\?id=$2&img_id=$3 [I]

2:includes/lib_common.php
build_uri
 $args = array('cid'   => 0,
                  'gid'   => 0,
                  'bid'   => 0,
                  'acid'  => 0,
                  'aid'   => 0,
                  'sid'   => 0,
                  'gbid'  => 0,
                  'auid'  => 0,
                  'sort'  => '',
                  'order' => '',
    
      'img_id' =>'0',
                );


case 'gallery':
    if (empty($gid))
            {
                return false;
            }
            else
            {
                if ($rewrite)
                {
                    $uri = 'gallery-'.$gid;
                 
                    if (isset($img_id))
                    {
                        $uri .= '-img'.$img_id;
                    }
                  
                }
                else
                {
                    $uri = 'gallery.php?id=' . $gid;
                  
                    if (isset($img_id))
                    {
                        $uri .= '&img_id=' . $img_id;
                    }
                  
                }
            }

   break;


3:includes/lib_goods.php
function get_goods_gallery($goods_id)
{
    $sql = 'SELECT img_id, img_url, thumb_url, img_desc' .
        ' FROM ' . $GLOBALS['ecs']->table('goods_gallery') .
        " WHERE goods_id = '$goods_id' LIMIT " . $GLOBALS['_CFG']['goods_gallery_number'];
    $row = $GLOBALS['db']->getAll($sql);
    /* 格式化相册图片路径 */
    foreach($row as $key => $gallery_img)
    {
        $row[$key]['img_url'] = get_image_path($goods_id, $gallery_img['img_url'], false, 'gallery');
        $row[$key]['thumb_url'] = get_image_path($goods_id, $gallery_img['thumb_url'], true, 'gallery');
  $row[$key]['url'] = build_uri('gallery', array('gid' => $goods_id,'img_id' => $gallery_img['img_id'] ), 'xxx');
    }
    return $row;
}


4:library/goods_gallery.lbi
 href="{$picture.url}"

来源:http://www.chinab4c.com

香港公司注册咨询