Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
4428 Представления

I was trying to figure out how to stop a t-foreach loop after a certain amount of runs


f.e.: I want to print my 5 latest products with all varibales

" t-as="product">



Right now, it runs through all of my products, but i want to stop the list after 5 products.

Is there a possibility

Аватар
Отменить
Лучший ответ

you can use t-set / t-value to save any value.
then in for loop you can increment this value and use t-if against this.
but this will iterate through all products but display only 5.



Аватар
Отменить
Лучший ответ

Use line_index which comes with t-foreach. The index is 0 based, so subtract 1

t-if="line_index < 4"

Аватар
Отменить
Related Posts Ответы Просмотры Активность
1
июл. 24
8812
1
мар. 15
17623
1
дек. 23
2596
1
июл. 25
1733
1
мая 25
1741