Message-ID: <1042989243.3348.1485852782630.JavaMail.confluence@ip-10-127-227-164> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_3347_1560951370.1485852782630" ------=_Part_3347_1560951370.1485852782630 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

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<= /h2>

ez_is_field_empty( eZ\Publish\Core\Repository\Val= ues\Content\Content content, eZ\Publish\API\Reposito= ry\Values\Content\Field|string fieldDefIdentifier[,= string forcedLanguage)

Argument name Type Description
content eZ\Publish\Core\Repository\V= alues\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

 

 

 

------=_Part_3347_1560951370.1485852782630--