Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
Why not check for the field's existence in an entry? – Bryan Redeagle Jun 26 '14 at 16:00
up vote 8 down vote accepted

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

{% if entry.possibleField is defined %}
{% else %}
{% endif %}

And here is more information on using is defined.

share|improve this answer
Thank you Patrick. – user1070143 Jun 26 '14 at 16:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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