I have a custom page template that's intended to display a couple of fields for a specific content type in an aside, along with the sidebar contents. My searching and reading seems to indicate that one of these should work:

{{ node.field_links }}
{{ node.field_links.value }}

However, these produce the following errors, respectively:

Object of type Drupal\Core\Field\FieldItemList cannot be printed. Object of type Drupal\link\Plugin\Field\FieldType\LinkItem cannot be printed.

I feel that I must be missing something very obvious here. How can I simply render the entire field, with all values, in the page template?

  • 1
    You can configure the rendered output of the field in the content type. Outside of the content type in the page template you can only get the URL from the LinkItem object and then build the link on your own, see drupal.stackexchange.com/questions/199262/… – 4k4 Dec 4 '18 at 19:44
  • Thank you -- that's what I was missing. I thought there had to be a "right way" to do it besides assembling the pieces myself, and that's simply not the case. Problem solved using a preprocessor. – WRD Dec 4 '18 at 22:45

Your Answer

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

Browse other questions tagged or ask your own question.