How to put an exact number of cakephp 2x pagination results

Asked

Viewed 45 times

0

I believe that by this code I can set an exact number of results per page in my pagination public $paginate = array('limit' => 7,); It’s just that the results don’t follow that number, and they come back random. I must move somewhere else?

1 answer

1


I guess that’s how you’re doing.

Examples:

Cakephp 3:

class ArticlesController extends AppController
{

    public $paginate = [
        'limit' => 25,
        'order' => [
            'Articles.title' => 'asc'
        ]
    ];

    public function initialize()
    {
        parent::initialize();
        $this->loadComponent('Paginator');
    }
}

Cakephp 2:

class PostsController extends AppController {

    public $components = array('Paginator');

    public $paginate = array(
        'limit' => 25,
        'order' => array(
            'Post.title' => 'asc'
        )
    );
}

But look for anything from Cakephp’s documentation. They always explain very well how their components work:

Documentation:

http://book.cakephp.org/3.0/en/controllers/components/pagination.html http://book.cakephp.org/2.0/en/core-libraries/components/pagination.html

Browser other questions tagged

You are not signed in. Login or sign up in order to post.