Laty Dior
Laty Dior

Reputation: 5

How to get a related object?

I have a class list_article with an attribute of type Relation Objects to retrieve article objects. What is the simplest way to get this related object in a Twig template?

Upvotes: 0

Views: 89

Answers (1)

Edi Modrić
Edi Modrić

Reputation: 2310

By default, you can't. The best you can do in Twig is to retreive the list of related content IDs with ez_field_value(content, 'my_relation_field').destinationContentIds.

To fetch the content objects themselves, your best bet would be to use a subrequest to execute a controller which loads the related content and then renders it in a separate Twig template.

Upvotes: 1

Related Questions