I have an Article object and I created findAll () in the controller.
I displayed each article in a div with class col-md-6 .
But for two articles, I have to wrap these divs in a div string.
How to do this with a twig?
Thanks.
EDIT:
I tried your code (NHG) as follows:
{% for article in articles %}
{% if loop.index % 2 == 0 %}
<div class="row"></div>
{% endif %}
<div class="col-md-6">
<article class="well well-sm">
<a href="#"><img src="{{ article.image }}" alt="{{ article.title }}" class="img-thumbnail"></a>
<h2 class="h3 text-center"><a href="#">{{ article.title }}</a></h2>
<div class="alert alert-success well-sm">
{{ article.content|striptags|slice(0, 235) }}...
</div>
<a class="btn btn-default btn-sm pull-right" href="#">{{ article.comments|length }} Comments</a>
<div class="btn-group btn-group-sm">
{% for tag in article.tags %}
<a class="btn btn-default">{{ tag.name }}</a>
{% endfor %}
</div>
</article>
</div>
{% endfor %}
But that will not work.
I want to have something like this:
<div class="row">
<div class="col-md-6"></div>
<div class="col-md-6"></div>
</div>
<div class="row">
<div class="col-md-6"></div>
<div class="col-md-6"></div>
</div>
<div class="row">
<div class="col-md-6"></div>
<div class="col-md-6"></div>
</div>
source
share