其他分享
首页 > 其他分享> > tp5无限极分类循环页面

tp5无限极分类循环页面

作者:互联网

	<section class="mt40">
	
		{foreach name="$data" id='val' key="k"}
			<section class="goods">
				<div class="title-h2 goods_head"><i></i><span>{$k}</span></div>
				<ul class="goods_main">
					{volist name="val.res" id="v"}
					<li>
						<a href="/subpage?id={$v.id}">
							<div class="pic"><div class="img"><img src="{$v.b_thumb}" style="width: 310px;height: 260px;"/></div></div>
							<div class="name f6">{$v.b_name}</div>
							<div class="desc">{$v.b_content}</br></div>
							<div class="btn"><div class="more"><span>查看更多</span><svg class="i svg_more" viewBox="0 0 6.46 8.85"><polyline class="cls-1" points="0.41 0.41 6.17 4.43 0.41 8.44"/></svg></div></div>
						</a>
					</li>
					{/volist}
				</ul>
				{if condition = "$val.has_next eq 1"}
				<a href="{:url('index/index/brand',['page'=>$val.page_1,'btid'=>$val.btid])}">
					<div class="load_btn"><div class="more"><span>加载更多</span><svg class="i svg_more" viewBox="0 0 6.46 8.85"><polyline class="cls-1" points="0.41 0.41 6.17 4.43 0.41 8.44"/></svg></div></div>
				</a>
				{else/}
					
				{/if}	
			</section>
		{/foreach}		

	</section>
	public function brand()
    {
        $model = new Brand();
        $btModel = new BrandType();
        $brandType = $btModel->select();
        $data = [];
        $btid = input('btid',0,'int');
        $limit = 6;
        $page = input('page','1','int');
        foreach($brandType as $v)
        {
            $value=[];
            if(empty($btid) || $v['id'] != $btid){
                $value['page_1'] = 2;
                $select=db('brand')->where(['bt_id' => $v['id']])->where(['is_delete' => 1])->paginate($limit,false,['page'=>1]);
            }else{
                $value['page_1'] = $page+1;
                $select= db('brand')->where(['bt_id' => $v['id']])->where(['is_delete' => 1])->paginate($limit*$page,false,['page'=>1]);
            }
            if(!$select->total()) continue;
            $value['has_next'] = $select->lastPage() > $select->currentPage() ? 1 : 0;
            $value['btid'] = $v['id'];
            $value['res'] = $select->items();
            // $res = $model->where(['bt_id' => $v['id']])->where(['is_delete' => 1])->page(0,6)->select();      
            $data[$v['title']] = $value;          
        }
        return $this->fetch('brand',['data' => $data]);
    }

标签:btid,无限极,value,page,tp5,where,id,select,页面
来源: https://blog.csdn.net/weixin_45557228/article/details/115376331