I want to print categories on top of my loop results. I'm using twig, but categories which I want to print are displaying every time beside iterations. I want to do it that way in order to spare some SQL request.
{% for goodies in goodies %}
{% if menus.bonbons == 'guimauve'%}
<div class="col-lg-3">Title</div>
{% endif %}
<div class="col-lg-3">{{ iterations }}</div>}
{% endif %}
{% endfor %}
Actually (logically) results are looking like this:
TITLE
iteration
TITLE
iteration
TITLE
iteration
TITLE
iteration
TITLE
iteration
TITLE
iteration
The result I want:
TITLE
iteration
iteration
iteration
iteration
iteration
iteration
iteration
Note that I won't place title before loop because I only want those title for existing categories.
TITLE iterationbecause of{% if loop.first %}'guimove'is actually spelled'guimauve'