Skip to the content
Documentation

ez_field_value: comparison of v.1 vs v.2

No ratings yet

Versions Compared

Old Version 1

changes.mady.by.user Dominika Kurek

Saved on Jul 08, 2016

compared with

New Version Current

changes.mady.by.user André Rømcke

Saved on Dec 31, 2016

Key

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

Comment: correct type hint on API and not internal implementation

Description

ez_field_value() is a Twig helper which returns a Content item's field value in the current language.

This can be useful when you don't want to use ez_render_field  and manage the rendering by yourself.

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_value( eZ\Publish\CoreAPI\Repository\Values\Content\Content content, string fieldDefIdentifier[, string forcedLanguage] )

Argument name Type Description
content eZ\Publish\CoreAPI\Repository\Values\Content\Content Content object the field referred to with fieldDefIdentifier belongs to.
fieldDefIdentifier string Identifier of the field we want to get the value from.
forcedLanguage string Locale we want the content name translation in (e.g. "fre-FR"). Null by default (takes current locale)

Usage

Code Block
<h2>My title value: {{ ez_field_value( content, "title" ) }}</h2>

Comments

Add a comment

Comments are read by a moderator before they appear.