0

Or to say it in a different way, paginate siblings.

I found this question on stack: How do you page through child entries in a structure? which seems to have a working answer. However trying this myself I get no results.

To be clear, I have a two level structure.

Level 1 (parent)
 - Level 2 (child)
 - Level 2 (child)
 - and so on..

How can I paginate the children?

Thank you for any input!

2

There are many ways to paginate:

To show next / prev links

#1 getPrevSibling getNextSibling

{% if entry.getPrevSibling %}
    <a href="{{entry.getPrevSibling.url}}">{{entry.getPrevSibling.title}}</a>
{% endif %}

{% if entry.getNextSibling %}
    <a href="{{entry.getNextSibling.url}}">{{entry.getNextSibling.title}}</a>
{% endif %}

#2 getPrev getNext

{% set params = {section: entry.section.handle} %}
{% set prev = entry.getPrev(params) %}
{% set next = entry.getNext(params) %}

{% if prev %}
    <a href="{{prev.url}}">{{prev.title}}</a>
{% endif %}

{% if next %}
    <a href="{{next.url}}">{{next.title}}</a>
{% endif %}

To show list of children (single type page)

{% paginate %}

{% paginate craft.entries.section('sectionHandle').limit(10) as pageEntries %}

{% for entry in pageEntries %}
    <article>
        <h1>{{ entry.title }}</h1>
        {{ entry.body }}
    </article>
{% endfor %}

{% if pageInfo.prevUrl %}<a href="{{ pageInfo.prevUrl }}">Previous Page</a>{% endif %}
{% if pageInfo.nextUrl %}<a href="{{ pageInfo.nextUrl }}">Next Page</a>{% endif %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.