【问题标题】:CakePHP 3 PaginationCakePHP 3 分页
【发布时间】:2017-06-22 08:37:16
【问题描述】:

我正在尝试为我的线程进行分页。

代码有效,但我想限制每页的帖子。

我怎样才能做到这一点? 以及如何将分页绘制到我的线程视图?

我的代码:

$this->paginate = [
         'contain' => 'posts'

        ];

     $query = $this->Threads->find('all')->where(['id' => $id]);
     $this->set('test', $this->paginate($query));

谢谢。

【问题讨论】:

    标签: cakephp pagination


    【解决方案1】:

    您是否尝试将限制选项传递给$this->paginate

    $this->paginate = [
        'contain' => ['Posts'],
        'limit' => 10 // limits the rows per page
    ];
    

    https://book.cakephp.org/3.0/en/controllers/components/pagination.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-09-14
      • 2016-12-29
      • 2016-10-09
      • 2014-08-04
      • 1970-01-01
      • 1970-01-01
      • 2015-06-26
      • 2016-01-02
      相关资源
      最近更新 更多