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 » Developer » Render relation objetcs on template...

Render relation objetcs on template twig

Render relation objetcs on template twig

Monday 30 October 2017 5:19:17 pm - 1 reply

Hi, i am new in ezpublish5 it's possible to explain me how to display the content of relation objects in the parent template.
Here my controller

public function getRelatedArticleAction($id, $show){

$repository=$this->getRepository();$searchService = $repository->getSearchService();$result=array();$query = new LocationQuery(); $criterionAnd = new Criterion\LogicalAnd( array() );$criterionAnd->criteria[] = new Criterion\Visibility( Criterion\Visibility::VISIBLE );$criterionAnd->criteria[] = new Criterion\ContentTypeIdentifier( "article" );$criterionAnd->criteria[]= new Criterion\FieldRelation('article_video',Operator::CONTAINS,array($id));
$query->sortClauses = array(new SortClause\DatePublished( Query::SORT_DESC )); $result=$searchService->findContent( $query )->searchHits;return $this->render("MyWebSiteBundle:render:view_related_article.html.twig", array('result'=>$result,'show'=>$show));





Modified on Monday 30 October 2017 5:54:59 pm by Laty Dior

Thursday 23 November 2017 6:06:54 pm

In your parent template:

 {{ render(controller(
      { 'id': 123, 'show':true  }
)) }}


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

36 542 Users on board!

Forums menu

Proudly Developed with from