General

  eZ Systems Website
  Editor documentation


  Developer documentation

  Back to the top

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Description

ez_field_name() is a Twig helper which returns a Content item's field FieldDefinition name in the current language.

This can be useful when you don't want to use a sub-request and custom controller to be able to display this information.

Info
If the current language cannot be found as a translation for content, the main language will be used. This behavior is identical when forcing a language using forcedLanguage.

Prototype and Arguments

ez_field_name( Content|ContentInfo content, string fieldDefIdentifier[, string forcedLanguage)

Argument nameTypeDescription
contenteZ\Publish\CoreAPI\Repository\Values\Content\Content or
eZ\Publish\CoreAPI\Repository\Values\Content\ContentInfo 
Content / ContentInfo object the fieldDefIdentifier belongs to.
fieldDefIdentifierstringIdentifier of the field we want to get the FieldDefinition name from.
forcedLanguagestringLanguage we want to force (e.g. "jpn-JP"), otherwise takes prioritized languages from SiteAccess settings.

Usage

Code Block
<label for="ez-content-article-title">{{ ez_field_name( content, "title" ) }}</label>