Display Suite node field in layouts Well it might be a simple solution but I don't get it.

I have a field in my content type "field_color". I can get the value of that field in my page.html.twig with {{ node.field_color.value }}

It works really good.

With Display Suite I created several layouts, but how to I access the field value within the layout.

I already tried:

{{ node.field_color.value }}
{{ ds_content.field_color.value }}
{{ ds_content.field_ }}
{{ ds_content.0 }}
{{ ds_content.1 }}
{{ ds_content.3 }}


nothing works.

Drupal 8, DS 2.5 stables

In my layouts.yml

sw_default_text:
  label: 'Text 1col Collapse'
  category: 'my cat'
  class: '\Drupal\ds\Plugin\DsLayout'
  template: layouts/sw_default_text/sw-default-text
  regions:
    middle:
      label: Content


My sw-default-text.html.twig:

{#
/**
 * @file
 * Template for a 1 column layout.
 *
#}
&lt;div {{ attributes.setAttribute('id', settings.css_id).addClass('row shrink', 'sw-default-text', settings.css_classes) }}&gt;
  &lt;div class="small-12 columns"&gt;
    {{ content.middle }}
  &lt;/div&gt;
&lt;/div&gt;
My suspicion is you are having an issue because you are trying to access this in a Display Suite template, rather than from a page template.

You can probably access it via {{ ds_region.field_color.0 }} in the ds-3col.html.twig file. Some notes:


Replace ds_region with the name of the ds_region you want - e.g. middle.
The 0 will mean it prints the first item in the array - if you only have one item, this should be enough
You will need to have the field in the region on your Manage Display page.
Once done, you can then print {{ left|without('body') }}.
Make sure to clear your cache


I hope this helps.

You could also try to {{ dump }} the variables and see what is available for you (or better still {{ kint }} if you have the devel module installed), that will help you drill down through the options to get the one you need.