How to pass a field value as contextual filter argument using Twig Tweak drupal_view?

05/07/2018


In Drupal 8, I’m using Twig Tweak to embed a view. I have a contextual filter set to one of the node’s fields, field_project_id. If I use a literal for the third argument, it works. If I try to reference the value of the current node’s project ID, no luck.

Works:
{{ drupal_view(‘my_view’, ‘block_1’, ‘2011-40054-000’) }}

Doesn’t work:
{{ drupal_view(‘my_view’, ‘block_1’, content.field_project_id) }},
{{ drupal_view(‘my_view’, ‘block_1’, content.field_project_id.value) }},
{{ drupal_view(‘my_view’, ‘block_1’, content.field_project_id.0) }},
{{ drupal_view(‘my_view’, ‘block_1’, content.field_project_id.0.value) }},
etc.

What’s the proper way to do this?

قالب وردپرس