ez_content_name: comparison of v.2 vs v.3
Versions Compared
Old Version 2
changes.mady.by.user Bertrand Dunogier
Saved on Dec 14, 2015
compared with
New Version Current
changes.mady.by.user Dominika Kurek
Saved on Jan 29, 2016
Key
- This line was added.
- This line was removed.
- Formatting was changed.
| Table of Contents |
|---|
| Info | ||
|---|---|---|
|
||
| This Twig helper is available as of Exponential 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( 'exponential.translation_helper' ); // From Content $translatedContentName = $translationHelper->getTranslatedContentName( $content ); // From ContentInfo $translatedContentName = $translationHelper->getTranslatedContentNameByContentInfo( $contentInfo ); |
...
Comments
Add a comment