2013-01-14 37 views

回答

2

使用slice功能:

{% for brand in colBrands %} 

     {% for article in brand.articles|slice(0, 5) %} 

      <!-- Display only 5 results and stop --> 

     {% endfor %} 

{% endfor %} 
+0

完美的事情,它的作品!非常感謝。 –

+0

速度怎麼樣?如果我有超過10000行?它會獲取所有行並只顯示5? –

+0

是的。在這種情況下,我不會推薦這種方法。 – Mike