Message-ID: <717586252.3812.1485855444507.JavaMail.confluence@ip-10-127-227-164> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_3811_1977302123.1485855444506" ------=_Part_3811_1977302123.1485855444506 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html ez_is_field_empty

ez_is_field_empty

=20
=20
=20
=20

Description

ez_is_field_empty() is a Twig helper which checks if a Cont= ent item's field value is considered empty in the current language.

It returns a boolean value (true or false).

If the current language cannot be found as a translation for content, the m= ain language will be used. This behavior is identical when forcing a langua= ge.

Prototype and Arguments<= /h4>

ez_is_field_empty( eZ\Publish\API\Repository\Valu= es\Content\Content content, eZ\Publish\API\Repositor= y\Values\Content\Field|string fieldDefIdentifier[, = string forcedLanguage)=

Argument name Type Description
content eZ\Publish\API\Repository\Va= lues\Content\Content Content object the displayable field belongs to.=
fieldDefIdentifier eZ\Publish\API\Repository\Va= lues\Content\Field or string
The field we want to check or its = identifier.
forcedLanguage string Locale we want the content name tr= anslation in (e.g. "fre-FR"). Null by default (takes current locale)

Usage

Using the F= ield identifier as parameter
=20
{# Display "description" field if not empty #}
{% if not ez_is_field_empty( content, "description" ) %}
    <div class=3D"description">
        {{ ez_render_field( content, "description" ) }}
    </div>
{% endif %}
=20
Using the Field as pa= rameter
=20
{# Display "description" field if not empty #}
{% if not ez_is_field_empty( content, field ) %}
    <div class=3D"description">
        {{ ez_render_field( content, field.fieldDefIdentifier ) }}
    </div>
{% endif %}
=20
Checking if fie= ld exists before use
=20
{# Display "description" field if it exists and is not empty #=
}
{% if content.fields.description is defined and not ez_is_field_empty( cont=
ent, "description" ) %}
    <div class=3D"description">
        {{ ez_render_field( content, "description" ) }}
    </div>
{% endif %}
=20
=20
=20
=20
=20

 

=20
=20
=20
------=_Part_3811_1977302123.1485855444506--