Running Drupal 8.9.18
I have a string that I want to pass to a Drupal block for use in a contextual filter. In a twig template I have a view that creates a simple list of the terms to use. I extract the string from the result array, map the required string to a variable that I pass as a parameter to another view block:
{% set view-output = drupal_block('views_block:view1-block_1') %}
{% for item in view-output.content['#view'].result %}
{% set qParam = item.taxonomy_term_field_data_name | render | striptags %}
{% if drupal_block('views_block:view2-block_1', qParam )is not empty %}
{{ drupal_block('views_block:view-name-block_1', qParam) }}
{% endif %}
{% endfor %}
The expression item.taxonomy_term_field_data_name | render | striptags
gives me the values I expect from the view output.
I get the following error:
The website encountered an unexpected error. Please try again later.
TypeError: Argument 2 passed to
Drupal\twig_tweak\TwigExtension::drupalBlock() must be of the type
array, string given,
Question: how can I pass qParam
as an array (it's a single value). I've tried using
{% set qParam = qParam|merge(..) %}
inside the for loop but the (..) bit is a mystery to me.
Or is there a better way of nesting queries that I don't know?
Note that I am not conversant with coding in PHP and want to stick with using Twig alone.
Thanks in anticipation for any help