eZ Community » Forums » eZ Publish 5 Platform » How do I get the value of an...
expandshrink

How do I get the value of an attribute in the current language without using "ez_render" in my template?

How do I get the value of an attribute in the current language without using "ez_render" in my template?

Wednesday 02 October 2013 7:20:39 pm - 5 replies

{{ ez_render_field(my_object, 'my_attribute') }} returns the attribute in the current language ($languages = $this->configResolver->getParameter( 'languages' ))
Now I need to get only the value thanks to {{ my_object.getFieldValue('my_attribute')}} but it returns the value in the main object language ($languageCode = $this->versionInfo->contentInfo->mainLanguageCode).     

 I tried {{ my_object.getFieldValue('my_attribute', app.request.locale)}} but 'app.request.locale' gives me "en-GB" whereas I'm looking for "eng-GB"…

Thanks for your help

Thursday 03 October 2013 9:11:58 am

Hi Irma

There is a new helper in upcoming 2013.09 / 5.2, but no twig function (yet).

See :

Thursday 03 October 2013 9:17:29 am

Thanks a lot for this quick reply!

Thursday 03 October 2013 9:42:02 am

Issue reported: https://jira.ez.no/browse/EZP-21676

Thursday 03 October 2013 9:53:30 am

Pull-request: https://github.com/ezsystems/ezpublish-kernel/pull/539

Thursday 03 October 2013 10:42:17 am

And... Implemented in master !

https://github.com/ezsystems/ezpu...2455ea9c717bb98bfee45188dfea6065beb3

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from