Yii paginate related data
What is the best way to paginate related data in Yii?
For example I may have post and I want 开发者_C百科to paginate comments.
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.
Look into CActiveDataProvider it already has inbuilt pagination support.
精彩评论