Code example of how to increase the total number of pages and records in LinkPager in yii2

黄舟
Release: 2023-03-15 20:50:02
Original
1905 people have browsed it

This article mainly introduces the example of LinkPager in php to increase the total number of pages and total records. It has certain reference value. Those who are interested can learn about it.

This article introduces the LinkPager in php to increase the total number of pages. Number and total number of records, share it with everyone, and leave a note for yourself

Project path vendor\yiisoft\yii2\widgets\LinkPager.php

Add ## to the renderPageButtons method


#

/****增加总页数***/

$buttons[] = Html::tag('li', Html::tag("span", '共'.$this->pagination->getPageCount().'页'), ['class'=>$this->pageCssClass]);

/****增加总条数***/

$buttons[] = Html::tag('li', Html::tag("span", '共'.$this->pagination->totalCount.'条记录'), ['class'=>$this->pageCssClass]);
Copy after login

Methods in models


use yii\data\Pagination;

$page = [

  'PageSize'=>10,//每页的数量

  'totalCount'=>(int) $obj->count(),//统计筛选后的数量

];

$list=$obj->offset($page->offset)

  ->limit($page->limit)

  ->all();

return [

  'list'=>$list,

  'page'=>$page

];
Copy after login

Usage method (view)


<?php

use yii\widgets\LinkPager;

?>

<?= LinkPager::widget([

  &#39;pagination&#39; => $pages,

  &#39;firstPageLabel&#39;=>"首页",

  &#39;prevPageLabel&#39;=>&#39;上一页&#39;,

  &#39;nextPageLabel&#39;=>&#39;下一页&#39;,

  &#39;lastPageLabel&#39;=>&#39;末页&#39;

]);?>
Copy after login

The above is the detailed content of Code example of how to increase the total number of pages and records in LinkPager in yii2. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!