Pagination In View Of Yii

I have set pagination in controller for list view

but in demo blog app

how can we limit the posts comments in pagination.

Here is code


<?php $this->renderPartial('_comments',array(

			'post'=>$model,

			'comments'=>$model->comments,

		)); ?>

It actually call the file _comments.php in same folder. I want to show 10 comments and after that pagination start inside the post view file.

Any help please.

Thanks

use CActiveDataProvider to get comments then give it to your view




//in your comment model in a function to get comments:


return $dataProvider = new CActiveDataProvider($this, array(

                                   'criteria' => $criteria, //if you have one.

				   'pagination' => array(

		                        'pageSize' => 10,

		                    ),

		                ));



I know how to do it

i have my indexaction as


	public function actionIndex()

	{

		$criteria=new CDbCriteria(array(

			'with'=>'post',

			'order'=>'t.status, t.create_time DESC',

		));


		$dataProvider=new CActiveDataProvider('Comment', array(

			'pagination'=>array(

				'pageSize'=>10,

			),

			'criteria'=>$criteria,

		));


		$this->render('index',array(

			'dataProvider'=>$dataProvider,

		));

	}

Its working fine for list all modules

If you look at official blog demo of /view/posts

you will see a _comment.php file which is rendered as partial as below


<?php foreach($comments as $comment): ?>

<div class="comment" id="c<?php echo $comment->id; ?>">


	<?php echo CHtml::link("#{$comment->id}", $comment->getUrl($post), array(

		'class'=>'cid',

		'title'=>'Permalink to this comment',

	)); ?>


	<div class="author">

		<?php echo $comment->name; ?> says:

	</div>


	<div class="time">

		<?php echo date('F j, Y \a\t h:i a',$comment->create_time); ?>

	</div>


	<div class="content">

		<?php echo nl2br(CHtml::encode($comment->content)); ?>

	</div>


</div><!-- comment -->

<?php endforeach; ?>

and this file is called via


		<?php $this->renderPartial('_comments',array(

			'post'=>$model,

			'comments'=>$model->comments,

		)); ?>

There is no controller in between them.

any suggestions…