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.
    – Kevin
    Commented Jan 15, 2019 at 15:37

1 Answer 1

1

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 %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.