TP5 對於數組使用分頁的方法


轉載自:https://my.oschina.net/u/3911977/blog/2872588
use think\Paginator\driver\Bootstrap; 

$all_idents = get_addon_list();//這里是需要分頁的數據

        $curPage = input('get.page') ? input('get.page') : 1;//接收前段分頁傳值
        $listRow = 1;//每頁2行記錄
        $showdata = array_slice($all_idents, ($curPage - 1)*$listRow, $listRow,true);// 數組中根據條件取出一段值,並返回
        
        $p = Bootstrap::make($showdata, $listRow, $curPage, count($all_idents), false, [
            'var_page' => 'page',
            'path'     => url('/admin/addons/index'),//這里根據需要修改url
            'query'    => [],
            'fragment' => '',
        ]);
        
        $p->appends($_GET);

        $this->assign('list', $p);
        $this->assign('listpage', $p->render());

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM