代码语言:javascript复制
<!--分页start-->
<div class="pager paging">
<?=
yiiwidgetsLinkPager::widget([
'pagination' => $pagination,
//设置样式
'options' => [
'class' => 'pagination',
],
'maxButtonCount' => 6,
'firstPageLabel' => '首页',
'lastPageLabel' => '末页',
'prevPageLabel' => '上一页',
'nextPageLabel' => '下一页',
'hideOnSinglePage' => true,
'disabledPageCssClass' => 'disabled',
]);
?>
<span>共 <?= $totalCount?> 条</span>
</div>
<!--分页end-->
编辑统一分页类
代码语言:javascript复制<?php
namespace frontendwidgets;
class LinkPager extends yiiwidgetsLinkPager
{
public $firstPageLabel = '首页';
public $prevPageLabel = '上一页';
public $nextPageLabel = '下一页';
public $lastPageLabel = '末页';
public $maxButtonCount = 6; //显示多少页
public $options = ['class' => 'pagination pull-right']; //css样式
public $totalTemplate = '<div class="pagination pull-right page-total-count" style="padding: 4px 10px;">总数:%s条</div>';//css样式
public function run()
{
if ($this->registerLinkTags) {
$this->registerLinkTags();
}
$buttons = $this->renderPageButtons();
if($this->totalTemplate)
{
$buttons = sprintf($this->totalTemplate, $this->pagination->totalCount).$buttons;
}
echo $buttons;
}
}
视图调用分页类
代码语言:javascript复制<?=
LinkPager::widget([
'pagination' => $pagination
]);
?>