My client has content tagged by a hierarchical taxonomy of arbitrary depth.
Currently the maximum depth is three, but that could change:
ParentTerm
└── ChildTerm
└── GrandchildTerm
Each Term has a unique TID (of course), but many Terms (especially descendants) share identical strings for Name.
However, the full Taxonomy tree path to each term is guaranteed to be unique (two adjacent Terms will never be identically named.)
All nodes tagged with GrandchildTerm
of TID = 42 appear in a View at /taxonomy/term/42
.
I would like to use Pathauto to generate aliases for each Term at the full taxonomy tree path, like so:
/ParentTerm/ChildTerm/GrandchildTerm
I was looking for Tokens to accomplish this.
I found instead that the paths are set by a View which generates the list of Nodes tagged with the Term ID.
The View has a contextual filter which accepts {{ arguments.tid }}
.
Under Page Settings, the value for Path is /taxonomy/term/%
.
Someone on this forum said setting up two contextual filters would help, but that does not apply here.
I do not want /taxonomyname/taxonomyterm
as the path; I want /ParentTerm/ChildTerm/GrandchildTerm
as the path (or, if necessary, /tags/ParentTerm/ChildTerm/GrandchildTerm
).
It is possible to set a contextual filter Content: Has taxonomy term ID (with depth)
but I haven't been able to get the path I seek this way.
Also, I would like a ParentTerm
taxonomy page to return results for its descendants, but the current View only displays items for the specific TID. (The Views Tree module would help here, but it does not work with Drupal 9 yet.)
If this were not a requirement, I might try flattening the taxonomy and using term names like ParentTerm-ChildTerm-GrandchildTerm
to differentiate identically named descendant terms. (This would solve another problem the client has: the ambiguity of selecting the correct term from the "Tags" vocabulary when tagging content.)