Quick view: I want to create a views block that lists all other nodes that have the same taxonomy term(s) and I want to group the related nodes by term.
I have trouble while doing this:
The content type has some taxonomy terms fields and one of them is my_taxonomy_field
. I can enter multiple values to this field.
What I basically want is to show all other nodes tagged with the term(s) on this node and group them by terms. I could do this by contextual filters (content: has taxonomy term ID + ) as explained here or here.
Let me explain:
This is my node list:
NODE 1 taxonomy term field: term 1, term 2, term 3
NODE 2 taxonomy term field: term 3, term 4
NODE 3 taxonomy term field: term 5, term 6, term 7
NODE 4 taxonomy term field: term 6, term 7
NODE 5 taxonomy term field: term 1, term 3
NODE 6 taxonomy term field: term 1
NODE 7 taxonomy term field: term 8
NODE 8 taxonomy term field: term 2, term 9
Let's look at NODE 1, it has these terms: term 1, term 2, term 3
And the terms are tagged on that nodes:
term 1: node 1, node 5, node 6
term 2: node 1, node 8
term 3: node 1, node 2, node 5
This is the related nodes block based on the taxonomy term field:
- node 1 (excluded)
- node 2
- node 5
- node 6
- node 8
I want to group them by terms as that (note that current node (node 1) excluded):
BLOCK
- TERM 1
- node 5
- node 6
- TERM 2
- node 8
- TERM 3
- node 2
- node 5
I tried to this with that way: views -> style -> settings (grouping field) and I selected the taxonomy term field. It does what I want, not what I want actually, more than what I want because it creates a views block as that:
BLOCK
- TERM 1
- node 5
- node 6
- TERM 2
- node 8
- TERM 3
- node 2
- node 5
- TERM 4
- node 2
- TERM 9
- node 8
This views doesn't add any (irrelevant) nodes to the list, the nodes are the same with the un-grouped one but because node 2 and node 8 are tagged with other terms, other terms listed here.
How I could list related nodes as grouped but without this 'unwanted' terms, with only the terms in the current node?
(Note: I'm working on both two ways mentioned above, these are the screenshots of them):