Info |
---|
title | Version compatibility |
---|
|
This Twig helper is available as of eZ Publish 5.2 / 2013.09 |
Description
ez_content_name()
is a Twig helper allowing to display which allows displaying a Content item's name in the current language.
Info |
---|
If the current language cannot be found as a translation for content, the name in the main language is always returned. This behavior is identical when forcing a language. |
...
Code Block |
---|
<h2>Content name in current language: {{ ez_content_name( 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, "fre-FR" ) }}</h2> |
Equivalent PHP code
Getting the translated name for a
...
Content item
Code Block |
---|
|
// Assuming we're in a controller action
$translationHelper = $this->get( 'ezpublish.translation_helper' );
// From Content
$translatedContentName = $translationHelper->getTranslatedContentName( $content );
// From ContentInfo
$translatedContentName = $translationHelper->getTranslatedContentNameByContentInfo( $contentInfo ); |
...