Score:-1

Access a user entity reference in a commerce-product template file

cn flag

I have a field_intervenantfield which contains a user entity reference. In the commerce-product template file, I want to access the description field of each intervenant.

How can I achieve it?

I tried reading the following values, but none of them returns what I am looking for.

  • product.field_intervenants.entity.field_description
  • product.field_intervenants.0.entity.field_description
  • product_entity.field_intervenants.0.entity.field_description
  • product_entity.field_intervenants.field_description
  • product_entity.field_intervenants.field_description.value

Do I need to loop through it, or am I missing something else?

Score:0
in flag

You should definitely use a loop, as the referenced entity fields returns an array, you can see an example here and adjust it by you own needs https://stackoverflow.com/questions/58291698/drupal-8-twig-entity-reference-sub-fields-templating

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.