- ๐บ๐ธUnited States thalemn
This thread was very helpful for my situation too. I embedded a view via twig tweak and needed to pass a taxonomy id value to the view contextual filter. The field from my content (commerce store) is a taxonomy field to toggle the use of Regular or Special/Holiday hours:
store.field_hour.
I set that field as a variable to use in the view:{% set hourActive = store.field_hour[0]['#plain_text'] %}
. So the embedded view looks like this:{{ drupal_view('hours', 'block_1', hourActive ) }}
.The part that I was missing was the ['#plain_text'] at the end of the field for the variable.
The other aspect of this solution was configuring the view contextual filter. After some experimenting, the solution that worked for me was to configure the contextual filter as: When the filter value is NOT available: Display contents of "No results found".
I also had to create a taxonomy relationship in the view, so the same taxonomy field used in the store (to toggle Regular or Special/Holiday hours), is used in the Hours content type to connect the two via the view contextual filter.
The result: a user can edit the store, select Regular or Special/Holiday hours, and easily switch between the two. I hope this helps others who have a similar situation.