Answer the question
In order to leave comments, you need to log in
How to stop {foreach} in Fenom template engine?
There is a loop that displays the characteristics of the product, I need to limit it to 5 iterations
{foreach $options as $option}
{$option.caption}
{if $option.value is array}
{$option.value | join : ', '}
{if $option.measure_unit?}
{$option.measure_unit}
{/if}
{else}
{$option.value}
{if $option.measure_unit?}
{$option.measure_unit}
{/if }
{/if}
{/foreach}
Answer the question
In order to leave comments, you need to log in
There is a suspicion that you are passing unnecessary data to the template engine ... Can you correct it and pass exactly as much as you need?
And so for your fenom it will be like this:
{foreach $options as $option index=$index}
{if $index == 5}
{break}
{/if}
{/foreach}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question