Skip to content

Instantly share code, notes, and snippets.

@plepe
Created September 25, 2023 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plepe/c860cc2f9f5d2d8d4ea35e3a31a09f91 to your computer and use it in GitHub Desktop.
Save plepe/c860cc2f9f5d2d8d4ea35e3a31a09f91 to your computer and use it in GitHub Desktop.
Drupal Display Suite - Twig Field Documentation

I couldn't find any documentation about Twig Fields using Display Suite, so I decided to create one on my own. You are very welcome to add more information.

Adding a Twig field in Drupal Display Suite, you can use the following syntaxes:

Render the ID of the current entity:

{{ entity.id }}

Render the value of a text field (called 'Foo'):

{{ entity.field_foo[0].value }}

This does not work (it will only generate "{}"):

{{ entity.field_foo|json_encode }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment