This page demonstrates how you can paginate data. All data comes in 1 feed (see here for data in several feeds)
Create a new JCI-Template for that:
- Name of Template: pagination
- URL: https://api.json-content-importer.com/extra/paginationdata.php
- urlparam4twig: no
- twig template:
{% set noonpage = 20 %}
{% set noofitems = ( days | length ) %}
{% if urlparam.no %}{% set selno = urlparam.no %}{% else %}{% set selno = 1 %}{% endif %}
number of data-items: {{ noofitems }} at <a href="https://api.json-content-importer.com/extra/paginationdata.php" target="_blank">https://api.json-content-importer.com/extra/paginationdata.php</a><br>
{% set noofpages = (noofitems /noonpage) | round(0, 'ceil') %} show on {{noofpages}} pages:
{% set start = noonpage *(selno-1) %}
{% set end= start + noonpage %}
{% for i in 1..noofpages %}
{% if i==selno %}
<b>this is page: </b> {{selno}} ({{start+1}} - {{end}})
{% else %}
<a href=?no={{i}}>{{i}}</a>
{% endif %}
{% endfor %}
<hr>
{% if noofitems ==0 %} No data-items found {% endif %}
<ul>
{% for day in days | slice(start, noonpage) %}
<li>
{% set currno = start + loop.index0+1 %} {{currno}}. {{day.FORENAMES}} {{day.SURNAME}}
</li>
{% endfor %}
</ul>
Shortcode:
[[jsoncontentimporterpro nameoftemplate=pagination]]
Example in action:
number of data-items: 165 at http://api.json-content-importer.com/extra/paginationdata.phpshow on 9 pages: 1 2 3 4 5 6 this is page: 7 (121 – 140) 8 9
- 121. Mendez Gilbert
- 122. Jensen Williamson
- 123. Montgomery Harvey
- 124. Oliver Howell
- 125. Dean Hanson
- 126. Weber Garrett
- 127. Sims Burton
- 128. Fuller Soto
- 129. Mccoy Welch
- 130. Chen Schultz
- 131. Walters Reid
- 132. Fields Walsh
- 133. Little Fowler
- 134. Bowman Davidson
- 135. May Day
- 136. Schneider Newman
- 137. Brewer Lucas
- 138. Holland Wong
- 139. Banks Santos
- 140. Curtis Pearson