0

I'm trying to create a featured content paragraph type, however, I can't figure out how to grab anything from the referenced node that is in my entity reference. I don't see any twig documentation that covers this seemingly crucial task at all either.

Does anyone know of a way to call something like get_node() within a twig template?

  • Just set the field formatter to Rendered Entity, select a View Mode or create a new one and configure it on the content type you are referencing. Then just add a new twig file and theme it, the field will render the referenced entity using that template. – Kevin Aug 9 '18 at 19:06
  • This would work but I need to place different fields around the paragraph template depending on other fields within the paragraph type. For instance, I have a field that places an image to one side of the content and the logic within the paragraph template places that image depending on the field. – wgallop Aug 9 '18 at 19:10
  • This feels like it should be pretty simple, I don't understand why I haven't been able to find a solution. – wgallop Aug 9 '18 at 19:13
1

If you're doing this in a node template you could access it like so

{{ node.field_paragraph.entity.field_in_paragraph.value }}

Obviously replace field_paragraph with the machine name of the paragraph field and field_in_paragraph with the machine name of the field inside the paragraph you want.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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