PHP7中文手册2018 带注释 最新chm版
控制器文件:
/** *yii pager * * @var $_pageObject */ private $_pageObject; /** * yii CDbCriterias * * @param $count 总数 */ public function cPagination($count = 0) { $criteria = new CDbCriteria (); $pager = new CPagination ( $count ? $count : '总数'); $pager->pageSize = '每页显示的数量'; $pager->applyLimit ( $criteria ); $this->_pageObject = $pager; return $this->_pageObject; } /** * 渲染视图 */ public function actionIndex() { $count = 1000; //总数 $this -> cPagination($count) ; $this -> render( 'index', array( 'pages' => $this->pageObject, 'list' => array(), //数据列表 ) ); }
views 视图文件:index.php
<div class="pager" style="text-align: right; margin-top: 20px; margin-right: 20px; font-size: 20px">
<?php $this->widget('CLinkPager',array( 'header'=>'', 'prevPageLabel' => '上一页', 'nextPageLabel' => '下一页', 'firstPageCssClass' => '', 'lastPageCssClass' => '', 'firstPageLabel' => '首页', 'lastPageLabel' => '末页', 'pages' => $pages, 'maxButtonCount'=>5, //分页数量 ) ); ?>
</div>
效果展示:
转载请注明:谷谷点程序 » yii CLinkPager 分页使用