I have an entity reference field. The referenced entity has multiple display modes.

I'd like to print this field 2 two times in a template, with 2 different display modes like so:

{{ content.field_ref_entity.display_mode_xy }}


{{ content.field_ref_entity.display_mode_yz }}

Is it possible to define the display mode of the referenced entity in field printing? If yes, how?

1 Answer 1


See my explanation in How can you render fields from an entity reference in node templates? [Drupal 8], which touches that topic as well.

In short, not with content, that can only contain a field once, at least without additional modules (not sure if display suite or so can do this). But you can call the view() mode on the field with either the of a view mode from where to pick the configuration or pass it the desired configuration directly. The structure is the same as what stored for the configuration in the entity view display config entities for a field.

Not sure about the exact twig syntax for the array, the view display would be like this: `{{ node.field_ref_entity.view('teaser') }}. You could also prepare it in preprocess and then just print a variable if building that configuration array is too tedious in twig.

Your Answer

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

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