Chris
Chris

Reputation: 8968

Yii paginate related data

What is the best way to paginate related data in Yii?

For example I may have post and I want to paginate comments.

Upvotes: 1

Views: 938

Answers (2)

Pentium10
Pentium10

Reputation: 207893

Look into CActiveDataProvider it already has inbuilt pagination support.

Upvotes: 0

Chetan Sharma
Chetan Sharma

Reputation: 2557

This can be achieved by using code like this, suppose you have CommentController.php having:

function listComments(){

 /* Write code here to fetch comments with current post from db and 
    return template code via calling renderPartial(). 
    Also implement paging, sorting etc. in this same function.
 */

}

After that call this function in action for view post page and pass the comment's listing code in view post template.

Upvotes: 1

Related Questions