Creating a switch based on entry handle I'm trying to create a switch statement for a single entry event template that has various entry fields associated with it (description, contact, location, etc.) from an Events Channel I have. Rather than using a bunch of IF's to display only those fields that have been populated, I'm trying to use a switch statement instead, but I can't get this to work when I based the switch on the 'entry.type." I'm trying to something like this, but it's not working. Any help would be appreciated!

{% switch entry.type %}
{% case 'contact' %}
    {{ entry.contact }}
{% case 'location' %}
    {{ entry.location }}
{% endswitch %}
It's a little unclear what you need to achieve here –

If your entries' entry type handles actually are 'contact' and 'location', the above code should work; which means that you've got an error somewhere that isn't really possible to figure out based on your description – e.g. the entry type handle is actually contacts, and not contact, or something like that.

One thing you might try, is to simply print the entry.type variable in a template, to see if it contains what you expect it to contain:

{{ entry.type }}


On the other hand, if your issue is simply that some entries have a contact field populated and others have a location field populated, you can't really use a {% switch %} statement in any sensible manner for that – though a plain old {% if %} would do it:

{% if entry.contact %}
    {{ entry.contact }}
{% elseif entry.location %}
    {{ entry.location }}
{% endif %}