4

I've got a generic template that can display entries from different channels. How in the template can I test if a field has been has been assigned to any given channel?

1
  • Why not check for the field's existence in an entry? Jun 26 '14 at 16:00
8

Twig has a "is defined" test that you can apply to a variable to see if it exists:

{% if entry.possibleField is defined %}
    Yup!
{% else %}
    Nope!
{% endif %}

And here is more information on using is defined.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.