我有以下代码:
$criteria=new CDbCriteria(array(
'condition'=>'status='.Post::STATUS_PUBLISHED,
'order'=>'sortOrder ASC',
'with'=>'commentCount',
));
$criteria->addSearchCondition('tags','home');
$dataProvider=new CActiveDataProvider('Post', array(
'pagination'=>array(
'pageSize'=>Yii::app()->params['postsPerPageHome'],
),
'criteria'=>$criteria,
));
$this->render('home',array(
'dataProvider'=>$dataProvider,
));
主页查看:
<?php foreach($dataProvider->getData() as $post) { ?>
// ....... displaying $post values
<?php } ?>
如何在上面的视图中显示分页。我搜索过它,我发现只使用zii.widgets.grid.CGridView,但这里我没有使用小部件。
答案 0 :(得分:3)
您需要CPagination
中的CActiveDataProvider
:
<?php $this->widget('CLinkPager', array(
'pages' => $dataProvider->pagination,
)); ?>