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? Commented Jun 26, 2014 at 16:00

1 Answer 1

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 and acknowledge you have read our privacy policy.

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