-2

Using {{ drupal_entity('node', '123', 'body') }} in a template file, I can get the node body and title.

Is there a way to get all the available node properties?

1
  • 2
    The last parameter is a view mode, not a field name.
    – Hudri
    Aug 26, 2022 at 11:30

1 Answer 1

2

The general solution is to preprocess the node.

If you want to avoid coding PHP, you can use Twig Tweak, which has a handy list of twig commands it adds:

Drupal Entity

{# Print a content block which ID is 1. #}
{{ drupal_entity('block_content', 1) }}

{# Print a node's teaser. #}
{{ drupal_entity('node', 123, 'teaser') }}

{# Print Branding block which was previously disabled on #}
{# admin/structure/block page. #}
{{ drupal_entity('block', 'bartik_branding', check_access=false) }}

Drupal Field

{{ drupal_field('field_image', 'node', 1) }}

{{ drupal_field('field_image', 'node', 1, 'teaser') }}

{{ drupal_field('field_image', 'node', 1, {type: 'image_url', settings: {image_style: 'large'}}) }}
1
  • One more way is using view filter as follows {{ node.body|view }}
    – ya.teck
    Aug 28, 2022 at 7:33

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.