0

I have content-type (Destination) with a paragraph added as a component. This paragraph has a referenced taxonomy vocabulary (location). I want to display a list of nodes from another content-type (Blogs) filtered by location.

I created a custom template for this paragraph and I want to send the taxonomy term as an argument to a view. In my twig template and using twig_tweaks, I set the location id as follow:{% set location = content.field_my_location[0]['#plain_text'] %} and I display the view with {{ drupal_view('my_view', 'my_view_display', location) }}.

The view displays when the contextual filter is set to display all results. I do not know how to filter by location.

I added my field that contains the paragraph as a relationship (field_components), then I added the location field (field_my_location) as a contextual filter. It does not work and I'm not sure what I'm doing wrong.

1 Answer 1

0

I was able to solve this by adding three relationship.

The first relationship is my blog location taxonomy term field "field_blog_location".

The second relationship I added is a referenced taxonomy term to the location field in the paragraph "Paragraph using field_my_location" This relationship is required.

The third relationship to add is the bridge to the Content entity that is referencing Taxonomy term via field_my_location_field_on_the_paragraph'. You set it up to use the second relationship as its relationship.

Last, you set up a contextual filter on field_my_location using the third relationship.

Hope it helps someone!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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