As we already know, the homepage of Quickwall shows all the questions that have been posted. This is a good thing, but what will happen when there will be many more questions? All the questions will be shown in the page, and as a result the page might be a big one! Also, it is not a good idea in terms of performance. One solution may be user paginations—so that all the questions are not shown together in a page, but divided into many pages.
Implementing pagination using CakePHP can be ridiculously easy. It is a default functionality in version 1.2.
In the
Questions
controller, add the following variable:<?php class QuestionsController extends AppController { var $name = 'Questions'; var $paginate = array('limit' => 5, 'page' => 1, 'order' => array('Question.created'=>'desc')); ... } ?>
In the home action of the
Questions
controller, change the following line:<?php class QuestionsController extends AppController { ... function home() { if...