1

In my content type for Event, I have an entity reference called Speakers which refers to a taxonomy called Team Members. It's set to multiple so I can say which speakers belong to my event. On the event detail page, I want to list the speakers out with all of their fields.

I have a field hook called field-field-speakers.html which lists all of the speakers. I can't seem to get any of the fields within the taxonomy. (ex: item.content.field_job_title ). It doesn't display any content.

 {% for item in items %} <div class="member"> <div class="name-box"> <div class="name"> {{ item.content }}</div> <div class="position">{{ item.content.field_job_title }}</div> </div> </div> {% endfor %} 

How do I do this? I think the answer might be in a View but not sure how to map it dynamically based on which event I am in.

1
  • 1
    Taxonomy is an entity, so you should have a custom View Mode for that, and change the field formatter setting on the Event (in the View Mode its using) to point to that view mode for rendering the term. Then they all become normal twig templates. Note, View Mode != Views. Commented Jan 15, 2019 at 15:37

1 Answer 1

2

You can use item.content['#options'].entity.field_job_title.value to get the value of the job_titlefield value, I don't know if this is the best way to do it.
So your code will be something like:

{% for item in items %} <div class="member"> <div class="name-box"> <div class="name"> {{ item.content }}</div> <div class="position">{{ item.content['#options'].entity.field_job_title.value }}</div> </div> </div> {% endfor %} 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.