1. 程式人生 > >TP5自帶分頁使用方法說明

TP5自帶分頁使用方法說明

public function index(){

        $business=db('archives')->where('cate_id=51')->field('id,title,litpic,time,cate_id')->order("time DESC")->limit(0,5)->select();
        $nav=db('cate')->field('id,cate_name,pid')->select();
            $news=db('archives')->where('cate_id=47')->field('id,title,keywords,description,writer,litpic,click,content,cate_id,model_id,time')->order("time DESC")->paginate(15);
        // 獲取分頁顯示
        $page = $news->render();
        $data = $news->all();
        foreach($data as $key=>$val){
          $data[$key]['key'] = $key;
        }
         $this->assign([
              'business'=>$business,
              'nav'=>$nav,
              'news'=>$news,
              'page'=>$page,
              'data'=>$data,
             ]);
         return $this->fetch();
       // return view();
    }

 

 <style type="text/css">
    .text-l{
      text-align: center;
    }
    .pagination{text-align:center;margin-top:20px;margin-bottom: 20px;}  
    .pagination li{margin:0px 5px; border:10px solid #e6e6e6;padding: 1px 2px;display: inline-block;font-size: 24px;}  
    .pagination .active{background-color: #dd1a20;color: #fff;}  
    .pagination .disabled{color:red;}  
  </style>