Forest header image

Symfony Finland
Random things on PHP, Symfony and web development

Check the existence of a field in a Content Object in eZ Publish in Twig

To check the existence of a specific field you can use Twig in eZ Platform:

{% if content.fields.cool_field is defined %}
    This content has a cool_field field!
{% else %}
    This content does NOT have a cool_field field!
{% endif %}

Kudos to Edi Modric for the tip, I was wasting time with this.


Written by Jani Tarvainen on Wednesday November 4, 2015
Permalink -

« Display Symfony debug toolbar in production (eZ Platform) - Fix: The requested package... could not be found in any version (eZ Publish) »