1

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?

2 Answers 2

1

Try using the attribute function.

http://twig.sensiolabs.org/doc/functions/attribute.html

attribute(ad, 'content_'~tld) should work.

Sign up to request clarification or add additional context in comments.

Comments

0

Try with this:

{{ ad["title_" ~ tld] }}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.