Add Pagination

When you have many records, you can use pagination to divide the records into multiple pages. Joomla! provides a simple way to include pagination to the list view and layouts.

The functionality is already defined in the parent class ListModel. You have to call the model method from the view file and display in the layout file.

Step 1: View File


Add the following line after getting items and state.

$this->pagination = $this->get('Pagination');

Step 2: Layout File


Add the following line after closing table tag.

<?php echo $this->pagination->getListFooter(); ?>

Add some records and change the number of records to display from the filter form. You will the pagination below the table.