eZ Community » Forums » eZ Publish 5 Platform » Twig Function Get the name with...

Twig Function Get the name with LocationId

Twig Function Get the name with LocationId

Thursday 13 November 2014 3:42:47 pm - 3 replies

Hi !

Is there an equivalent of ez_urlalias for get the name with location Id ? https://doc.ez.no/display/EZP/Twig+functions

I don't find it in



Thursday 13 November 2014 5:58:56 pm

no not in kernel, but there is nothing stopping someone to make a bundle that provides these kind of fetch functions of course, as it would on the php side be a Repository->getLocationService->loadLocation( $locationId );

However what kind of context is this?
As in: Why no ContentInfo or Location (which also contains ContentInfo) in this context provided by controller?

Thursday 13 November 2014 6:34:40 pm

Hi Johann

If you are using a custom controller you can just pass the other content object to your template using the $params parameter and use {{ ez_content_name(my_other_content) }}.


If you want to make something more general for your project, but you don't want to create a twig function then you can create another view and use a general template for it


                        template: "MyWorkBundle:Name:post.html.twig"
                        match: { Identifier\ContentType: [post] }


Then in this new template

{# Template to render the name of a post content type #}
{{ ez_content_name(content) }}

Now in your real template you can start using it

 {% set location_id = 123 %}
<a href="{{ path( "ez_urlalias", {"locationId": location_id} ) }}">{{ render(controller('ez_content:viewLocation', { 'locationId': location_id, 'viewType': 'custom_view' } ) ) }}</a>

The other two ways are creating a new a twig function or creating a custom controller to get the name of a location.

Friday 14 November 2014 8:54:04 am

Thank you for yours answer happy.gif Emoticon


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

36 542 Users on board!

Forums menu

Proudly Developed with from