part
A part in the navigation for pagination.
{
"is_link": true,
"title": "2",
"url": "/collections/all?page=2&phcursor=eyJhbGciOiJIUzI1NiJ9.eyJzayI6InBvc2l0aW9uIiwic3YiOjIwLCJkIjoiZiIsInVpZCI6MzY5MTI0Nzk3NjQ2NTksImwiOjIwLCJvIjowLCJyIjoiQ0RQIiwidiI6MSwicCI6Mn0.rlQnBhrVp_ZXLZBZRzrYxxDDKfpaPSH2UmkttMttC0s"
}
{
"is_link": true,
"title": "2",
"url": "/collections/all?page=2&phcursor=eyJhbGciOiJIUzI1NiJ9.eyJzayI6InBvc2l0aW9uIiwic3YiOjIwLCJkIjoiZiIsInVpZCI6MzY5MTI0Nzk3NjQ2NTksImwiOjIwLCJvIjowLCJyIjoiQ0RQIiwidiI6MSwicCI6Mn0.rlQnBhrVp_ZXLZBZRzrYxxDDKfpaPSH2UmkttMttC0s"
}
You can create a pagination navigation by iterating over each part
of a paginate
object.
When paginating, part.url
may contain a phcursor
parameter in addition to page
. This optional parameter is used to improve performance when navigating between pages.
{% paginate collection.products by 5 -%}
{% for part in paginate.parts -%}
{% if part.is_link -%}
{{ part.title | link_to: part.url}}
{%- else -%}
<span>{{ part.title }}</span>
{% endif %}
{%- endfor %}
{%- endpaginate %}
{% paginate collection.products by 5 -%}
{% for part in paginate.parts -%}
{% if part.is_link -%}
{{ part.title | link_to: part.url}}
{%- else -%}
<span>{{ part.title }}</span>
{% endif %}
{%- endfor %}
{%- endpaginate %}
{
"collection": {
"products_count": 19
}
}
Output
<span>1</span>
<a href="/services/liquid_rendering/resource?page=2" title="">2</a>
<a href="/services/liquid_rendering/resource?page=3" title="">3</a>
<a href="/services/liquid_rendering/resource?page=4" title="">4</a>
Was this section helpful?