Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-01T12:18:32.173Z
Answers.LastActivityDate: 2016-09-01T12:18:32.173Z
Answers.UserDisplayName: Jan
Body: <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>
  
Tags: <matrix><pagination>
Title: Paginate a matrix
ThreadText: # 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' %}
          <section id="{{ inhoud.title|kebab }}" class="segment">
              <h2 class="section-h2">{{ inhoud.title }}</h2>
          </section>
      {% 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' %}
              <section id="{{ inhoud.title|kebab }}" class="segment">
                  <h2 class="section-h2">{{ inhoud.title }}</h2>
              </section>
          {% 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 %}
              <div class="pagination" style="border-bottom: 0;">
                  <div class="w-row">
                      <div class="pagination-left w-col w-col-6">
                          <div>pagina {{ pageInfo.currentPage }} van {{ pageInfo.totalPages }}</div>
                      </div>
                      <div class="pagination-right w-col w-col-6">
                          <a class="pag-link">
                              {% if pageInfo.prevUrl %}
                              <a class="pag-link" href="{{ pageInfo.prevUrl }}"></a>{% endif %}
                              {% for page, url in pageInfo.getPrevUrls(2) %}
                                  <a href="{{ url }}" class="pag-link">{{ page }}</a>
                              {% endfor %}
                              <span>{{ pageInfo.currentPage }}</span>
                              {% for page, url in pageInfo.getNextUrls(2) %}
                                  <a class="pag-link" href="{{ url }}">{{ page }}</a>
                              {% endfor %}
                              {% if pageInfo.nextUrl %}
                              <a class="pag-link" href="{{ pageInfo.nextUrl }}"></a>{% endif %}
                          </a>
                      </div>
                  </div>
              </div>
          {% endif %}
      {% endfor %}
  
  ```
  
  
  ---
  
  