default_ pagination
paginate | default_pagination
returns string
Generates HTML for a set of links for paginated results. Must be applied to the paginate object.
{% paginate collection.products by 2 %}
{% for product in collection.products %}
{{- product.title }}
{% endfor %}
{{- paginate | default_pagination -}}
{% endpaginate %}
Code
{% paginate collection.products by 2 %}
{% for product in collection.products %}
{{- product.title }}
{% endfor %}
{{- paginate | default_pagination -}}
{% endpaginate %}Data
{
"collection": {
"products": [
{
"title": "Draught of Immortality"
},
{
"title": "Glacier ice"
}
],
"products_count": 4
}
}Output
Draught of Immortality
Glacier ice
<span class="page current">1</span> <span class="page"><a href="/services/liquid_rendering/resource?page=2" title="">2</a></span> <span class="next"><a href="/services/liquid_rendering/resource?page=2" title="">Next »</a></span>
Anchor to previous
previous
paginate | default_pagination: previous: string
Specify the text for the previous page link.
{% paginate collection.products by 2 %}
{% for product in collection.products %}
{{- product.title }}
{% endfor %}
{{- paginate | default_pagination: previous: 'Previous' -}}
{% endpaginate %}
Code
{% paginate collection.products by 2 %}
{% for product in collection.products %}
{{- product.title }}
{% endfor %}
{{- paginate | default_pagination: previous: 'Previous' -}}
{% endpaginate %}Data
{
"collection": {
"products": [
{
"title": "Draught of Immortality"
},
{
"title": "Glacier ice"
}
],
"products_count": 4
}
}Output
Draught of Immortality
Glacier ice
<span class="page current">1</span> <span class="page"><a href="/services/liquid_rendering/resource?page=2" title="">2</a></span> <span class="next"><a href="/services/liquid_rendering/resource?page=2" title="">Next »</a></span>
Anchor to next
next
paginate | default_pagination: next: string
Specify the text for the next page link.
{% paginate collection.products by 2 %}
{% for product in collection.products %}
{{- product.title }}
{% endfor %}
{{- paginate | default_pagination: next: 'Next' -}}
{% endpaginate %}
Code
{% paginate collection.products by 2 %}
{% for product in collection.products %}
{{- product.title }}
{% endfor %}
{{- paginate | default_pagination: next: 'Next' -}}
{% endpaginate %}Data
{
"collection": {
"products": [
{
"title": "Draught of Immortality"
},
{
"title": "Glacier ice"
}
],
"products_count": 4
}
}Output
Draught of Immortality
Glacier ice
<span class="page current">1</span> <span class="page"><a href="/services/liquid_rendering/resource?page=2" title="">2</a></span> <span class="next"><a href="/services/liquid_rendering/resource?page=2" title="">Next</a></span>
Anchor to anchor
anchor
paginate | default_pagination: anchor: string
Specify the anchor to add to the pagination links.
{% paginate collection.products by 2 %}
{% for product in collection.products %}
{{- product.title }}
{% endfor %}
<div id="pagination">
{{- paginate | default_pagination: anchor: 'pagination' -}}
</div>
{% endpaginate %}
Code
{% paginate collection.products by 2 %}
{% for product in collection.products %}
{{- product.title }}
{% endfor %}
<div id="pagination">
{{- paginate | default_pagination: anchor: 'pagination' -}}
</div>
{% endpaginate %}Data
{
"collection": {
"products": [
{
"title": "Draught of Immortality"
},
{
"title": "Glacier ice"
}
],
"products_count": 4
}
}Output
Draught of Immortality
Glacier ice
<div id="pagination"><span class="page current">1</span> <span class="page"><a href="/services/liquid_rendering/resource?page=2#pagination" title="">2</a></span> <span class="next"><a href="/services/liquid_rendering/resource?page=2#pagination" title="">Next »</a></span></div>
Was this page helpful?