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

一页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,
    ]) ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 python+selenium,在新增时弹出了一个输入框
  • ¥15 苹果验机结果的api接口哪里有??单次调用1毛钱及以下。
  • ¥20 学生成绩管理系统设计
  • ¥15 来一个cc穿盾脚本开发者
  • ¥15 CST2023安装报错
  • ¥15 使用diffusionbert生成文字 结果是PAD和UNK怎么办
  • ¥15 有人懂怎么做大模型的客服系统吗?卡住了卡住了
  • ¥20 firefly-rk3399上启动卡住了
  • ¥15 如何删除这个虚拟音频
  • ¥50 hyper默认的default switch