<span style="font-family: Arial, Helvetica, sans-serif; white-space: normal; ">利用CPagination实现</span>
在 Controller中如下代码:
[html] view plaincopy
public function actionIndex()
{
$criteria = new CDbCriteria();
$criteria->order = 'createtime desc';
$count = Article::model()->count($criteria);
$pager = new CPagination($count);
$pager->pageSize = 10;
$pager->applyLimit($criteria);
$artList = Article::model()->findAll($criteria);
$this->render('index',array('pages'=>$pager,'list'=>$artList));
}
在视图中代码如下:
[html] view plaincopy
<div id="pager">
<?php
$this->widget('CLinkPager',array(
'header'=>'',
'firstPageLabel' => '首页',
'lastPageLabel' => '末页',
'prevPageLabel' => '上一页',
'nextPageLabel' => '下一页',
'pages' => $pages,
'maxButtonCount'=>13
-->
转载请注明:谷谷点程序 » Yii 分页方法总结