Limit

On this page

Overview 

Below you can see all the available drops on the limit object


Name Description
limit.first Returns the first element of the collection
limit.size Returns the size of the collection
limit.count Returns the size of the collection
.[limit] Set the numner of items per page to limit. For instance, show 12 items per page:
  {% for g in articles.all.12 %}
    ...display...
  {% endfor %}
.[limit]_[initial_offset] Set the numner of items per page to limit, and skips the first initial_offset items. For instance, show 12 items per page; but skip the first 3::
  {% for g in articles.all.12_3 %}
    ...display...
  {% endfor %}
initial_offset The initial offset that has been set. Only meaningful after it has been set as above. Defaults to 0.
current_page The current page the drop is on.
total_pages The total number of pages available. Note that the number of items per page must be set first for it to be accurate:
  {{ assign pagination = articles.all }}
  {{ pagination.count }} <- Lets say this is 120
  {{ pagination.total_pages }}  <- Would be 120 / 10 here = 12
  {% for g in pagination.all.12 %}
    ...display...
  {% endfor %}
  {{ pagination.total_pages }}  <- Per page has been set to 12, so the total number of pages is now 10.
first_page True if it is the first page, same as current_page == 1, but easier to read.
last_page True if it is the last page, same as current_page == total_pages, but easier to read.
current_items The items in the drop, for when you need to set up first.
  {{ assign pagination = articles.all }} <- Creates a new limit drop
  {% for g in pagination.all.12 %} <- Configures the drop to show 12 items per page
    ...display...
  {% endfor %}
  {% for g in pagination.current_items %} <- Repeats the loop from above.
    ...display...
  {% endfor %}

 

Updated: 2022-08-11