PaginatedList - 0.9.5

PaginatedList

Variable Name PaginatedList
Version 0.9.5

Description

PaginatedList objects are a type of List object with a few differences.

Like Lists, Paginated Lists contain one or more regular objects. However since the particular list is expected to potentially contain a very large number of items, for performance and speed reasons, you can only retrieve a certain number of items from the list at a time, hence the list is paginated (meaning it is split into multiple pages).

Accessing Items in a Paginated List

You cannot access items in a Paginated List in the same way you can with a regular List.

Instead, items in a Paginated List can be accessed with in one of the following ways.

1. Lookup syntax

Use the PaginatedList’s key field to find the item. For example, the documentation for the all_products PaginatedList variable (see Global Object) indicates that the key field is slug. You can use the slug value to find a product in the all_products Paginated List.

{{ all_products["product-slug-here"] }}

2. Loop using for tag inside a paginate tag

You can loop over the Paginated List if you first wrap it in a paginate tag:

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

Here we have wrapped the Paginated List variable in a paginate tag and specified that each page contains 25 items.

For more information, see the documentation for the paginate tag

Attributes

Paginated Lists have the following attributes:

Attribute Type Description
size Number Returns the number of items in this List
first Various Returns the first item in the List
last Various Returns the last item in the List

Back to Variable List

Back to Liquid Reference for 0.9.5

 

 
Back to Documentation