In a pagination block, this type will be provided within the paginate variable. The structure contains the following elements:
Variable name | Object | Description | Note |
current_page | int | Contains the number of the currently displayed page. | |
current_offset | int | This contains the number of items on the previous pages. If you are paginating by 8 (items per page), then you will receive an offset of 40 when being on page 6 (5 times 8). | |
items | int | Total number of items to be iterated (on all pages). | |
parts | List<Part> | Contains a list which specify details about each page navigational component. This list can be used to create a navigation bar for choosing a different page. This will include Part objects for the previous and next page (relative to the current one). | |
next | Part | Returns the Part object for the next page. | |
previous | Part | Returns the Part object for the previous page. | |
page_size | int | Contains the maximum number of items displayed per page (the last page could contain fewer items than this value). | |
pages | int | Specifies the total number of pages available. |
A filter exists which transforms this object into a navigational structure automatically. Of course this navigation block has only a basic navigation and look & feel functionality. In order to customize the pagination exactly to your needs, you would need to write your own pagination function. The following example shows how the default pagination works. For an example on how to build your own pagination routine, please have a look at the Part object description.
Example:
{% paginate collection.products by 2 %}
{% for p in collection.products %}
{{ p.title }}
{% endfor %}
{{ paginate | default_pagination }}
{% endpaginate %}
Output:
Tears of Steel
Sintel
<div class="parts">
<span class="item current">1</span>
<a href="/?page=2" class="item link">2</a>
<a href="/?page=3" class="item link">3</a>
</div>