2016-12-30 28 views
0

私のtwigテンプレートにはforループがあり、それに変数を追加しようとしています。これはどうすればいいですか?変数付きのTwigテンプレート

( 'var')は、変数>コンテンツである必要があります。 + var + .related.buttons

{% include '@PleinCatalog/Theme/includes/themeCatergory.html.twig' with {'var':'something'} %} 
{% for button in content.('var').related.buttons %} 
     <a href="{{ button.url }}" class="btn btn-block btn-success">{{ button.title }}</a> 
{% endfor %} 
+1

私はそれがこの 'のように動作するはずだと思う{コンテンツにおけるボタンの%[VAR] .related.buttons%}のような' –

+0

作品魅力..ありがとう! – Christien

答えて

2

私のプロジェクトでは、いくつかのオプションを含むテンプレートを含む類似のforループがあります。あなたの例に基づいて

- それはそのような用途に使用できます

{% for button in content[var].related.buttons %} 
    … 
{% endfor %} 
関連する問題