Hey all,
I’m working on something difficult. I’ve given a max range of items for a array and want to wrap a div around the result after the max range is passed. So here is my try. In the web i found a plugin where I can add a break into the for loop but GRAV didn’t have this plugin.
PS: Maybe someone has a better solution to do THIS.
MD
—md
modal: true # More button appear and the items are limited to 'maxitems’
maxitems: 2 # Default 2
lazyload: false
jobs:
*TWIG*
---twig
{% if not page.header.modal %}
{% for job in page.header.jobs %}
<li class="jobs-item">
<p>{{ job.text }}</p>
<div class="info">
<icon data-name="{{ job.icon }}"></icon>
<ul>
<li>{{ job.title }}</li>
<li>{{ job.area }}, {{ loop.index }}</li>
</ul>
</div>
</li>
{% endfor %}
{% else %}
{% set continue = true %}
{% for job in page.header.jobs %}
{% if loop.index <= page.header.maxitems %}
<li class="jobs-item">
<p>{{ job.text }}</p>
<div class="info">
<icon data-name="{{ job.icon }}"></icon>
<ul>
<li>{{ job.title }}</li>
<li>{{ job.area }}, {{ loop.index }}</li>
</ul>
</div>
</li>
{% else %}
{% set continue = true %}
{% endif %}
{% endfor %}
{% if continue %}
<div class="md-more">
{% for job in page.header.jobs %}
{% if loop.index > page.header.maxitems %}
<li class="jobs-item">
<p>{{ job.text }}</p>
<div class="info">
<icon data-name="{{ job.icon }}"></icon>
<ul>
<li>{{ job.title }}</li>
<li>{{ job.area }}, {{ loop.index }}</li>
</ul>
</div>
</li>
{% endif %}
{% endfor %}
</div>
{% endif %}
{% endif %}
---