Witm mam to tai sobie kod
{% for post in posts %} {% if loop.first %} {% set i = i + 1 %} <http://december.com/html/4/element/div.html class="step-{{ i }}">{% for post in posts|slice(0 , loop.index + 3) %}{{ post.PostId }}{% endfor %}</http://december.com/html/4/element/div.html> {% elseif loop.index % 4 == 0 and not loop.last %} {% set i = i + 1 %} <http://december.com/html/4/element/div.html class="step-{{ i }}">{% for post in posts|slice(loop.index , loop.index + i) %}{{ post.PostId }}{% endfor %}</http://december.com/html/4/element/div.html> {% endif %} {% endfor %}
Zrobiłbym tak:
- pętla na "posts" zostaje,
- jeśli loop.first drukowanie otwarcia "<div>",
- jeśli loop.index%4==0 i nie loop.last, drukowanie zamknięcie i otwarcia "</div><div>",
- jeśli loop.last "</div>",
- w międzyczasie drukowanie postId,
- step obliczany z intval(loop.index0/4)+1
dzieki działa idealnie temat do zamkniecia
Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)