douningqiu4991
2018-12-19 11:55
采纳率: 0%
浏览 141
已采纳

一页YII2上的两个分页

I can’t do two paginations on one page. I have a page in the form of tabs, and each tab has a list of different products, I want to paginate each list Here is the error code and screenshot

$posts = Wishlist::find()->where(['user_id'=>$id]);
$pagination =new Pagination([

    'defaultPageSize' =>10,
    'totalCount' => $posts->count()
]);

$posts = $posts->offset($pagination->offset )->limit($pagination->limit)->all();


$favs = FavLists::find()->where(['user_id'=>$id]);
$pag_favs =new Pagination([

    'defaultPageSize' =>10,
    'totalCount' => $favs->count()
]);

$favs = $favs->offset($pag_favs->offset )->limit($pag_favs->limit)->all();


    return $this->render('view', [
        'model' => $this->findModel($id),
        'posts' =>$posts,
        'pagination' => $pagination,
        'favs' =>$favs,
        'pag_favs' => $pag_favs
    ]);

In view 1st pagination

          echo LinkPager::widget([
             'pagination' => $pagination,
          ]);

          ?>

In view 2nd pagination

<?php 

          echo LinkPager::widget([
            'pag_favs' => $pag_favs,
          ]);

          ?>

enter image description here

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dtx9763 2018-12-20 11:23
    已采纳

    Replace pag_fvs with pagination in LinkPager. LinkPager don't have property page_fvs.

    <?= LinkPager::widget([
        'pagination' => $pag_favs,
    ]) ?>
    
    已采纳该答案
    打赏 评论

相关推荐 更多相似问题