Reputation: 8968
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
Reputation: 207893
Look into CActiveDataProvider it already has inbuilt pagination support.
Upvotes: 0
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