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

ez_content_name

=20
=20
=20
=20

Description

ez_content_name() is a Twig helper which allows displaying = a Content item's name in the current language.

If the current language cannot be found as a translation for content, the n= ame in the main language is always returned. This behavior is identical whe= n forcing a language.

Prototype and Arguments

ez_content_name( eZ\Publish\API\Repository\Values= \Content\Content content[, string forcedLangu= age)
ez_content_name(
<= strong>contentInfo[, string = forcedLanguage) 

Argument name Type Description
content eZ\Publish\API\Repository\Va= lues\Content\Content
or
eZ\Publis= h\API\Repository\Values\Content\ContentInfo 
Content or ContentInfo object the displayable fi= eld belongs to.
forcedLanguage string Locale we want the content name tr= anslation in (e.g. "fre-FR"). Null by default (takes current locale)

Usage

 

=20
<h2>Content name in current language: {{ ez_content_name(&nbs=
p;content ) }}</h2>
<h2>Content name in current language, from ContentInfo: {{ ez_content=
_name( content.contentInfo ) }}</h2>
<h2>Content name in french (forced): {{ ez_content_name( content, "fr=
e-FR" ) }}</h2>
=20

Equivalent PHP code

Getting = the translated name for a Content item
=20
// Assuming we're in a controller action
$translationHelper =3D $this->get( 'ezpublish.translation_helper' );
 
// From Content
$translatedContentName =3D $translationHelper->getTranslatedContentName(=
 $content );
// From ContentInfo
$translatedContentName =3D $translationHelper->getTranslatedContentNameB=
yContentInfo( $contentInfo );
=20
Forcing a specific lang= uage
=20
// Assuming we're in a controller action
$translatedContentName =3D $this->get( 'ezpublish.translation_helper' )-=
>getTranslatedName( $content, 'fre-FR' );
=20

=20
=20
=20
=20

 

=20
=20
=20
------=_Part_3795_1776084582.1485855405838--