Search code examples
cakephpcakephp-2.4

Paginator limit not working


I am using cakephp 2.4 .I am trying to use cake Paginator component.But here Paginator limit not working.I have tried below code in controller.

class TutorialsController extends AppController
    {
        public $components = array('Paginator');
        public $paginate = array(
        'limit' => 3
        );

        public function index()
        {
            $this->Tutorial->recursive =0;
            $this->set('tutorials', $this->Paginator->paginate());
        }

    } 

Solution

  • Never mix component and controller pagination. Both itself work just fine, but mixing them can cause trouble as you can see.

    So either don't include the component and use $paginate alone, or use

    $this->Paginator->settings()
    

    inside the actions. You can also directly pass settings in your $components array, as well.