Of course, you may be thinking about lot of things that we can do to upgrade our application's CRUD. We will see some that are quite useful, for example, pagination—something that is needed in almost every project. Also, we are going to see how to order our records.
Paginating our results is a good way of making life easier for our visitors, as they won't need to search through thousands of records. For us, developers, paginating will be very easy; with this CI class, it will be implemented in a matter of seconds. Want to see how? Let's start. Open your application/controllers/sites.php
file, take a look at the index
function, that's the one we will modify.
For our pagination to work we need to make some changes. First, change the following line:
function index()
To:
function index($page = "0")
This will help us determine the page and the function call we are in, the default being the first one. Also, we need to change our model function call:
$sites = $this...