Quantcast
Channel: Jonasen's Blog » ecshop
Viewing all articles
Browse latest Browse all 4

ecshop分页实现与分析

$
0
0

最近被ecshop的商品分页卡住了,因为自己添加了三个参数,生成的url传不了这三个参数,于是仔细分析了一下ecshop分页函数,总结了下经验,我修改的是品牌页面的商品。
首先要将索要传递的参数赋值:

$a1=$_GET['a1'];
$a2=$_GET['a2'];
$a3=$_GET['a3'];
if(empty($a3)){
	$sql="select v9_luntai_fenlei.id as chelei from v9_luntai_fenlei left join ecs_goods on".
        "(v9_luntai_fenlei.id=ecs_goods.chelei) where ecs_goods.brand_id='$brand_id' group by".
        "v9_luntai_fenlei.id order by v9_luntai_fenlei.px asc limit 0,1";
	$a3temp=$GLOBALS['db']->getAll($sql);
	$a3=$a3temp[0]['chelei'];
}else{
	$a3=$_GET['a3'];	
}

然后传递给assign_pager类

assign_pager('brand', $cate, $count, $size, $sort, $order, $page, '', $brand_id, 0, 0,
 $display,'','','',$a1,$a2,$a3);

然后构建assign_pager接收参数,该函数所在页面/includes/lib_main.php

function assign_pager($app, $cat, $record_count, $size, $sort, $order, $page = 1,
$keywords = '', $brand = 0, $price_min = 0, $price_max = 0, $display_type = 'list', $filter_attr='', 
$url_format='', $sch_array='',$a1=0,$a2=0,$a3=0)//这里要给自己所做的参数赋初始值

然后在switch(app)块中接收参数

case 'brand':
            $uri_args = array('cid' => $cat, 'bid' => $brand, 'sort' => $sort, 'order' => $order,
 'display' => $display_type,'a1'=>$a1,'a2'=>$a2,'a3'=>$a3);//因为我用的是brand模块,所以在这里修改brand

接下来是做重要的一步,修改构建url函数 该函数名称build_uri所在页面/includes/lib_common.php

function build_uri($app, $params, $append = '', $page = 0, $keywords = '', $size =
 0,$a1='',$a2='',$a3='')//同样接收自定义参数并且赋值
if (!empty($a3))
                    {
                         $uri = 'ltbrand.php?id=' . $bid;
                    }else
					{
						 $uri = 'brand.php?id=' . $bid;
					}
                   
					if (!empty($a1))
                    {
                        $uri .= '&a1=' . $a1;
                    }
					if (!empty($a2))
                    {
                        $uri .= '&a2=' . $a2;
                    }
					if (!empty($a3))
                    {
                        $uri .= '&a3=' . $a3;
                    }
                    if (!empty($cid))
                    {
                        $uri .= '&cat=' . $cid;
                    }
                    if (!empty($page))
                    {
                        $uri .= '&page=' . $page;
                    }
                    if (!empty($sort))
                    {
                        $uri .= '&sort=' . $sort;
                    }
                    if (!empty($order))
                    {
                        $uri .= '&order=' . $order;
                    }
//酱紫就完成了 HOHO 我这个可比网上的详细多了!!!这才叫二次开发啊

Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images