Answer the question
In order to leave comments, you need to log in
How to write such a construction on TWIG?
There is such a design.
{% for product in order%}
{{ loop.index }}
{% endfor %}
<?
$i = 0;
for (/*условие цикла*/) {
$i++;
}
echo $i+1;
?>
Answer the question
In order to leave comments, you need to log in
In fact, such tasks should not be in front of the template. If you need to do this in Twig, look for troubles in your architecture. Twig is not an equivalent of PHP, its task is to output variables that are received in the controller to the template. In your case, you can simply get the number of elements in the array, either before or after the for:{{ order|length }}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question