【发布时间】:2012-08-01 06:58:35
【问题描述】:
我有class categroies 和class Products。
在我的存储库中我有功能
getProducts($categoryid,$location)
我需要像这样在树枝模板中循环
{% for category in categories %}
--{{ category.name }}--
{% for product in getProducts(category.id,location) %}
--{{ product.name }}--
{% endfor %}
{% endfor %}
或者有什么更好的方法
【问题讨论】:
-
你试过 {% for item in product.items %} 吗?
-
我认为你应该创建一个 Twig 扩展。看看this topic
标签: php symfony doctrine-orm twig