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?

nicael
  • 2,382
  • 7
  • 27
  • 48
user1070143
  • 1,106
  • 12
  • 24

1 Answers1

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.

nicael
  • 2,382
  • 7
  • 27
  • 48
Patrick Harrington
  • 1,080
  • 6
  • 9