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

eZ Community » Forums » eZ Platform » Related objects to the parent...

Related objects to the parent location of the current location

Related objects to the parent location of the current location

Monday 20 June 2016 3:19:22 pm - 2 replies

Back on the eZ track, I'm currently making a new version of, all in eZ Platform. I'm getting there, slowly, but there are some obsticles.

If I want to fetch the content of related objects to the parent location of the current location in a twig template. What do I do? 

Monday 20 June 2016 10:28:32 pm

I believe you will first have to get the relations in the view controller and use the search API to get the related content.,finding,viewing-Relations 

Saturday 02 July 2016 1:58:02 pm

Hi Felix,

in the current location you don't have content infoemations about the parentLocation.

Proceed Like these:

1. you can get the parentLocationId with:

 {{  location.parentLocationId }}

-> PS: {{ dump (location) }} can give you more information

2. Call a controller where you can get location and content info of the parentLocation,something like

 {{ render( controller( "YOUR-BUNDLE:CLASS-NAME:METHOD-NAME", { 'parentLocation':
location.parentLocationId  } )) }}

3. In the contoller you can use something like this :

         $repository = $this->container->get( 'ezpublish.api.repository' );
        $query = new Query();
        $query->criterion = new Criterion\LogicalAnd(
                new Criterion\LocationId( $parentLocation)
        $searchService = $repository->getSearchService();
        $searchResult = $searchService->findContent($query);
// echo here the $searchResult  for more Informations about the parentLocation content.

 4. In a new Twig template you have now the content of your parentLocation.

5. You wil get only the ContentIds of your related objects at this step.

6. Use something Like "ez_content:viewAction" to render the content of the related Objects. (

Using ez_content controller:

I hope this will help you

Modified on Saturday 02 July 2016 2:00:18 pm by Ramzi Arfaoui


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

36 542 Users on board!

Forums menu

Proudly Developed with from