paginate - Liquid Tag Reference - 1.0.0

Tag Name paginate
Version 1.0.0

Description

Split record data across multiple pages. You can paginate a List or a PaginatedList.

Examples

{% paginate all_products by 25 %}
  {% for product in all_products %}
    ...
  {% endfor %}
{% endfor %}

Inside the paginate tag you have access to a paginate variable to help you build the navigation links to go back and forward page by page.

Paginate Object

Attribute Type Description
current_offset Number Returns the index number of the first item in the current page
current_page Number Returns the number of the currently loaded page
first Part Returns the first page Part
last Part Returns the last page Part
next Part Returns the next page Part
page_size Number Returns the number of items to show for each page
pages Number Returns the total number of pages
param_name String Returns the request param that controls page number for this list
parts List[Part] Returns a list of page Parts
previous Part Returns the previous page Part
records Number Returns the total number of items in the list
window Number Returns the number of items to show in the navigation either side of the current page

Parts

The Parts list represents a set of links for the pagination navigation.

It doesn’t include links to all pages, just the current page and an amount either side, called a “window”.

The Parts List will contain a Gap Part at the start, end or both if the list contains more pages outside the window.

If there are not enough parts on one end to fully use the window, the equivalent amount is added to the other end if there is room. This is so the total number of parts remains the same across pages.

Examples

Here a Gap part is represented by an ellipsis (...)

window=5, total pages: 13, current page=1
[1] 2 3 4 5 6 7 8 9 10 11 ...

window=5, total pages: 13, current page=6
1 2 3 4 5 [6] 7 8 9 10 11 ...

window=5, total pages: 13, current page=7
... 2 3 4 5 6 [7] 8 9 10 11 12 ...

window=5, total pages: 13, current page=9
... 3 4 5 6 7 8 [9] 10 11 12 13

You can set the window using the window option:

{% paginate all_products by 25 window 10 %}
  {% for product in all_products %}
    ...
  {% endfor %}
{% endfor %}

Part Object

Attribute Type Description
current? Boolean Indicates whether this page Part is the current page
gap? Boolean Indicates whether this Part represents a gap marker in the navigation
page Number Returns the page number of this page Part. Blank if this Part is a gap.
url String Returns the url to this page Part. Blank if this Part is a gap.

Back to Tag List

Back to Liquid Reference for 1.0.0

 

 
Back to Documentation