This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit ezplatform.com

eZ Community » Forums » eZ Publish 5 Platform » Render object related - content ID
expandshrink

Render object related - content ID

Render object related - content ID

Thursday 10 April 2014 3:19:57 pm - 4 replies

I would like to render object related I do as bellow :

 {% set relatedContentIds = content.fields.block[location.contentInfo.mainLanguageCode].destinationContentIds %}
 
{#afficher les blosks de présentations services#}
{% for relatedContentId in relatedContentIds %}
     {{ render(controller('ez_content:viewContent', {
        'locationId': relatedContentId,
        'viewType': 'line',
        'layout' : 'DdorresiProBundle:Line:service_block.html.twig'
    })) }}
{% endfor %}

The problem is that the ''relatedContentId' is the object ID and I can't reach this object like this.It works if a put a static node ID.

If anyone as an idea about my mistake.

Thanks

Monday 02 June 2014 11:01:45 am

Hello,

I have the same problem. Is anyone can explain how to display an object related in a twig template ?

I try to override the object with "viewContent" controller like this :

 {{ render ( controller("ez_content:viewContent", {'contentId': ez_field_value(registration, 'training'), 'viewType' : 'line'})) }}

The template is overrided in a YAML file like this :

 system:    front:        content_view:            line:                registration_cart:                    template: "CnppTrainingSiteBundle:registration:line/registration.html.twig"                    match:                        Identifier\ContentType: cnpp_registration

It displays the name of the object but not the template I choose in the override file.

Or is there a way to retrieve a node id with an related object attribute ?

 

Thanks

Monday 02 June 2014 1:42:56 pm

@Bru: I guess you only have to replace 'locationId' by 'contentId' when using ez_content:viewLocation, see https://doc.ez.no/display/EZP/Content+view

Cheers,
Donat

Monday 02 June 2014 3:36:28 pm

No it doesn't work even with the 'contentId'.

 

Another idea maybe ?

 

Thanks

Monday 02 June 2014 6:20:15 pm

The problem is solved. The override didn't match on the good class ^^

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from