Using Twig how can I get the summary of the body field to use in a template?

by Sorin   Last Updated December 29, 2017 19:07 PM

So I have a textarea with summary and I want to display the summary before the content. So if I just use {{ content.body }} the text is displayed without the summary.

How can I get the summary ?

{{ content.body.summary }} doesn't seem to do the trick

Tags : theming fields 8

Answers 2

The only way I managed to solve this is:

if you only want to target the value of the summary, you can target the entity you're on. If you're on a node then you can do this :


In a paragraph


You can also get the summary front content like this :


Not great but will do for now.

February 04, 2016 11:45 AM

In your THEME.theme file you can just define it too:

function THEME_preprocess_node(&$variables) {
$variables['node_teaser'] = $node_array['body'][0]['summary'];

And then display it with:

{{ node_teaser }}
Mike Gifford
Mike Gifford
December 29, 2017 18:13 PM

Related Questions

How to render field attribute in foreach

Updated April 28, 2015 21:03 PM

Split content data and display field data in node theming

Updated September 26, 2016 09:03 AM

Images instead of radio buttons in node/add form

Updated May 16, 2017 10:07 AM