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