The final override we will look at is the pagination override. This override can control the display of items-per-page and the pagination links used with lists of information, as shown in the following screenshot.

Typical Joomla! page showing a paginated list.

The rhuk_milkyway template provides a well-commented example for this override. The file is found here:

/templates/rhuk_milkyway/html/pagination.php

When the pagination list is required, Joomla! will look for this file in the default templates. If it is found, it will be loaded and the display functions it contains will be used.

There are four functions that can be used:

pagination_list_footer

This function is responsible for showing the select list for the number of items to display per page.

pagination_list_render

This function is responsible for showing the list of page number links as well at the Start, End, Previous and Next links.

pagination_item_active

This function displays the links to other page numbers other than the “current” page.

pagination_item_inactive

This function displays the current page number, usually not hyperlinked.

Cheat Sheet

Using the rhuk_milkyway template as an example, here is a brief summary of the principles we’ve looked at.

Customise the Component Output

To override a component layout (for example the default layout in the article view), copy:

/components/com_content/views/article/tmpl/default.php

to:

/templates/rhuk_milkyway/html/com_content/article/default.php

Read more about component output.

Customise the Module Output

To override a module layout (for example the Latest News module using the rhuk_milkyway template), copy:

/modules/mod_latest_news/tmpl/default.php

to:

/templates/rhuk_milkyway/html/mod_latest_news/default.php

Read more about module output.

Add New Module Styles

To add new module styles (chrome), add them to the following file:

/templates/rhuk_milkyway/html/modules.php

Read more about module chrome.

Customise the Pagination Links

To customise the way the items-per-page selector and pagination links display, edit the following file:

/templates/rhuk_milkyway/html/pagination.php