<p>Found the answer - I had to paginate the children of "inhoud". Works like a charm now :-)</p>

<pre><code>    {% for inhoud in entry.getDescendants() %}
        {% if inhoud.type == 'segment' %}
            &lt;section id="{{ inhoud.title|kebab }}" class="segment"&gt;
                &lt;h2 class="section-h2"&gt;{{ inhoud.title }}&lt;/h2&gt;
            &lt;/section&gt;
        {% endif %}

    {% paginate inhoud.children.limit(10) as pageInfo, pageEntries %}
        {% for inhoud in pageEntries %}
           {% for inhoud in inhoud.trace %}
              {% include ["trace/" ~ inhoud.type, "trace/default" ] %}
            {% endfor %}
        {% endfor %}

     {% if pageInfo.totalPages&gt;1 %}
            &lt;div class="pagination" style="border-bottom: 0;"&gt;
                &lt;div class="w-row"&gt;
                    &lt;div class="pagination-left w-col w-col-6"&gt;
                        &lt;div&gt;pagina {{ pageInfo.currentPage }} van {{ pageInfo.totalPages }}&lt;/div&gt;
                    &lt;/div&gt;
                    &lt;div class="pagination-right w-col w-col-6"&gt;
                        &lt;a class="pag-link"&gt;
                            {% if pageInfo.prevUrl %}
                            &lt;a class="pag-link" href="{{ pageInfo.prevUrl }}"&gt;&lt;/a&gt;{% endif %}
                            {% for page, url in pageInfo.getPrevUrls(2) %}
                                &lt;a href="{{ url }}" class="pag-link"&gt;{{ page }}&lt;/a&gt;
                            {% endfor %}
                            &lt;span&gt;{{ pageInfo.currentPage }}&lt;/span&gt;
                            {% for page, url in pageInfo.getNextUrls(2) %}
                                &lt;a class="pag-link" href="{{ url }}"&gt;{{ page }}&lt;/a&gt;
                            {% endfor %}
                            {% if pageInfo.nextUrl %}
                            &lt;a class="pag-link" href="{{ pageInfo.nextUrl }}"&gt;&lt;/a&gt;{% endif %}
                        &lt;/a&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
            &lt;/div&gt;
        {% endif %}
    {% endfor %}
</code></pre>

CC BY-SA 3.0
2016-09-01T12:18:32.173Z
2016-09-01T12:18:32.173Z
Jan
<p>I'm in need of help (again ;-) )...
I'm trying to paginate the content of a matrix in a structure, but can't seem to get it done... This is the code I've got:</p>

<pre><code>{% for inhoud in entry.getDescendants() %}
    {% if inhoud.type == 'segment' %}
        &lt;section id="{{ inhoud.title|kebab }}" class="segment"&gt;
            &lt;h2 class="section-h2"&gt;{{ inhoud.title }}&lt;/h2&gt;
        &lt;/section&gt;
    {% endif %}
    {% if inhoud.type == 'inhoud' %}
    {#{% paginate inhoud.trace.limit(10) as inhoud %}#}
        {% for inhoud in inhoud.trace %}
            {% include ["trace/" ~ inhoud.type, "trace/default" ] %}
        {% endfor %}
    {% endif %}
{% endfor %}
</code></pre>

<p>My pagination code is in comments since it doesn't work, but that's where I need the pagination. Is there anyone nice enough to want to help me figure this out?
We've got a big matrix field (it's the route of certain products from farm 'till the shop, so lots of blocks in there), and I'd like to paginate the content of these 'segments', but we'll need those segments printed out because there's a navigation with anchorpoints on top of the site.
Thanks!</p>

<matrix><pagination>
Paginate a matrix
# Paginate a matrix

(Asked by: username_0 on 2016-08-31)

I'm in need of help (again ;-) )...
I'm trying to paginate the content of a matrix in a structure, but can't seem to get it done... This is the code I've got:
{% for inhoud in entry.getDescendants() %}
    {% if inhoud.type == 'segment' %}
        
            {{ inhoud.title }}
        
    {% endif %}
    {% if inhoud.type == 'inhoud' %}
    {#{% paginate inhoud.trace.limit(10) as inhoud %}#}
        {% for inhoud in inhoud.trace %}
            {% include ["trace/" ~ inhoud.type, "trace/default" ] %}
        {% endfor %}
    {% endif %}
{% endfor %}

My pagination code is in comments since it doesn't work, but that's where I need the pagination. Is there anyone nice enough to want to help me figure this out?
We've got a big matrix field (it's the route of certain products from farm 'till the shop, so lots of blocks in there), and I'd like to paginate the content of these 'segments', but we'll need those segments printed out because there's a navigation with anchorpoints on top of the site.
Thanks!

**Tags:** matrix, pagination


---

## 1 answers

### Answer by username_0 on 2016-09-01. Score: 2

Found the answer - I had to paginate the children of "inhoud". Works like a charm now :-)
    {% for inhoud in entry.getDescendants() %}
        {% if inhoud.type == 'segment' %}
            
                {{ inhoud.title }}
            
        {% endif %}

    {% paginate inhoud.children.limit(10) as pageInfo, pageEntries %}
        {% for inhoud in pageEntries %}
           {% for inhoud in inhoud.trace %}
              {% include ["trace/" ~ inhoud.type, "trace/default" ] %}
            {% endfor %}
        {% endfor %}

     {% if pageInfo.totalPages>1 %}
            
                
                    
                        pagina {{ pageInfo.currentPage }} van {{ pageInfo.totalPages }}
                    
                    
                        
                            {% if pageInfo.prevUrl %}
                            {% endif %}
                            {% for page, url in pageInfo.getPrevUrls(2) %}
                                {{ page }}
                            {% endfor %}
                            {{ pageInfo.currentPage }}
                            {% for page, url in pageInfo.getNextUrls(2) %}
                                {{ page }}
                            {% endfor %}
                            {% if pageInfo.nextUrl %}
                            {% endif %}
                        
                    
                
            
        {% endif %}
    {% endfor %}


---

