0

I have following code in action:

$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,    
));

home View:

<?php foreach($dataProvider->getData() as $post) { ?>     
            // ....... displaying $post values
       <?php } ?>

How can I display the pagination in above view. I have searched for it, I found only using with zii.widgets.grid.CGridView but here I haven't use the widget.

4

1 回答 1

3

You need the CPagination from the CActiveDataProvider:

<?php $this->widget('CLinkPager', array(
    'pages' => $dataProvider->pagination,
)); ?>
于 2013-06-28T06:09:56.860 回答