Skip to Content
मेन्यू
This question has been flagged
2 Replies
4422 Views

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

Avatar
Discard
Best Answer

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.



Avatar
Discard
Best Answer

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

t-if="line_index < 4"

Avatar
Discard
Related Posts Replies Views Activity
1
जुल॰ 24
8802
1
मार्च 15
17621
1
दिस॰ 23
2593
1
जुल॰ 25
1729
1
मई 25
1736