0

I would like to divide a list of items in two column with Twig.

For the moment my list get 10 items so I can put 5 items in each column with batch(5). But if I add items in the future in my back office after 10 items a new column will be create and I don't want a new column.

How to get the length of my list and split the items automatically in two columns ?

{% for row in bloc.team_references_repeater|batch(5) %}
<div class="col-tn-12 col-xs-6 col-md-3">
    <ul class="team__references-list">
        {% for item in row %}
        <li class="team__references-item"><a href="{{ item.team_references_link }}" class="team__references-link">{{ item.team_references_name }}</a></li>
        {% endfor %}
    </ul>
</div>
{% endfor %}
Jandon
  • 605
  • 7
  • 32
  • Possible duplicate of [Divide datas into 2 columns list using Twig](https://stackoverflow.com/questions/48188356/divide-datas-into-2-columns-list-using-twig) – DarkBee Nov 08 '19 at 05:41
  • Or just use [css](https://stackoverflow.com/questions/14745297/how-to-display-an-unordered-list-in-two-columns) – DarkBee Nov 08 '19 at 05:43

0 Answers0