Reputation: 461
I have this in my template
{{ ad.title_de }}
Now I'm incorporating multiple languages, so 'title_de' has to change I also have a variable 'tld' which is one of de, en , fr
So I'd like to have something like
{% if tld == 'fr' %}
{{ ad.title_fr }}
etc Any ideas?
Upvotes: 1
Views: 2029
Reputation: 1793
Try using the attribute
function.
http://twig.sensiolabs.org/doc/functions/attribute.html
attribute(ad, 'content_'~tld)
should work.
Upvotes: 1