1

I've been trying to get the following working for a couple of hours:

I have a views block, it displays a single content type. The content type has a taxonomy field. The taxonomy items are structured as this:

- option A
- option B
- option C
- - option C1
- - option C2
- - option C3
- option D

I use the values to categorize the content of the nodes. Each node has a single taxonomy value and displays the view block itself.

I want the view to display all nodes of the same taxonomy (this is no problem for A, B and D). But for content tagged as C1, C2 and C3 I want to show all content within the parent taxonomy, "option c".

I have tinkered with depth and parent fields for relations/contextual filters without success... don't really know what to try next and I can't find and decent resources with similar examples that solves my problem. I would prefer to solve it within the views UI if possible.

1
  • Can you add the info about the structure of the C nodes and which depth you want to show in the block, it's not very clear to me.
    – prkos
    Nov 5, 2020 at 19:22

1 Answer 1

0

If your content type contains a reference field to a taxonomy term with depth, you can use a view block with a normal filter, no contextual filter needed.

  • Choose 'add filter' > 'Has taxonomy terms (with depth)'
  • Next screen, select the taxonomy vocabulary (I don't know what it's name is in your case, it should be the vocabulary in which 'option c' is a term) and set 'Depth' to 1, this will also select the first level of children
  • Next screen, select the parent term for c1, c2 and c3 (in your case 'option c')

The block will now show all content where the reference field has been used to select option C or it's children.

I used this technique in this site: www.zorgsaamwonen.nl which uses 3 main themes with a lot of child themes.

2
  • Thanks, I'll give it a go. But I would need a contextual filter to view C2 and C3 as related content through the C-parent when viewing C1 for example, which I guess would be the next step.
    – Lenny
    Nov 5, 2020 at 21:50
  • The context is given when a piece of content is made from the content type that has the reference field to the taxonomy terms. Selecting one or more of them will have them show up in the view block.
    – C.A. Vuyk
    Nov 6, 2020 at 7:22

Your Answer

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

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