0

The only way I found yet is to use {{ drupal_entity('node', '123', 'body') }} in a template file.

That always gives me the node body and title (even when I pass 'title' as last parameter).

Is there a way to get a specific node to then get the available node properties?

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

1 Answer 1

3

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 at 7:33

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.