Hi!
I want to use collection with choosen template only and i want to paginate it.
I try to use ofType method, but my collection looks strange - like an array which contains empty value or something similar.
Look:
.md file header
—
title: Home
content:
items:
page@.descendants: /notes
exclude: topic
limit: 3
order:
by: date
dir: desc
pagination: true
—
Folder structure:
And part of template code:
{% set collection = page.collection.ofType('note') %}
{% for child in collection %}
{% set image = child.media['_header.jpg'] %}
{% set image = image ? image : child.media.images|randomize|first %}
{% include 'partials/preview.html.twig' with {'child': child, 'image':image} %}
{% if not loop.last %}
<div>
<hr class="note-hr"/>
</div>
{% endif %}
{% endfor %}
{% if config.plugins.pagination.enabled and collection.params.pagination %}
<div class="pure-g">
<div class="pure-u-1 text-center">
{% include 'partials/pagination.html.twig' with {'base_url':page.url, 'pagination':collection.params.pagination} %}
</div>
</div>
{% endif %}
I thought this collection should contains only 4 elements, and i expected to got only 2 pages with 3 and 1 item
But i get - 3 pages and first page empty and others contains 2 items each:
page 1
page 2
page 3