0

In a custom twig template for content type "legal", I'm trying to loop through a 3-field paragraph called "legal_section." It's referenced by my content type, using an entity reference field called "field_legal_section" - set to allow unlimited entries. For each, I want to print the paragraph id. I'm not quite sure how, in this scenario. Maybe there's a little more involved than I thought?

I'm currently trying something like this, in the twig template:

{% if content.field_legal_section %}
 {% for item in content.field_legal_section %}
  id: {{ content.field_legal_section.id }}<br/>
  show the 3 fields: {{ content.field_legal_section }}
 {% endfor %}
{% endif %}

If relevant, the individual fields within the paragraph called legal_section are:

 field_legal_section_title
 field_legal_section_subtitle
 field_legal_section_body
  • Per our conversation in the other link, This comes very close to the other task, with the slight difference of needing the paragraph id, which isn't a field? – turpentyne May 23 '19 at 2:03
  • Is this in the Paragraph template? – Kevin May 23 '19 at 12:17

Browse other questions tagged or ask your own question.