تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
4635 أدوات العرض

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"

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
يوليو 24
9277
1
مارس 15
17843
1
ديسمبر 23
2771
1
يوليو 25
2173
1
مايو 25
2438