一页YII2上有两个分页

时间:2018-12-19 11:55:09

标签: php yii yii2

我无法在一页上进行两种分页。我有一个选项卡形式的页面,每个选项卡都有一个不同产品的列表,我想对每个列表进行分页 这是错误代码和屏幕截图

$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
    ]);

在第一分页中      

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

          ?>

在第二个分页中

<?php 

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

          ?>

enter image description here

1 个答案:

答案 0 :(得分:0)

在LinkPager中将pag_fvs替换为pagination。 LinkPager没有属性page_fvs

<?= LinkPager::widget([
    'pagination' => $pag_favs,
]) ?>