0

I'm using Path auto module to automatically set url of articles. Last part of url is node title and [node:title] works just fine. But url part before node title should follow taxonomy structure (tree) of tag used for tagging that article (taxonomy name: "structural_category".

So i.e. if article is tagged with tag "Child" and that tag has parent tag called "Parent" then url of my article should be:

/parent/child/node-title

I can get only Child tag with tokens like this: [node:field_structural_category:0], but I don't see the way to get Child's tag parent with token. With "Browse available tokens" I just can't drill any deeper than tag which is used directly for tagging the article.

For Drupal 7 I found that there is a solution with "join" keyword, something like:

[term:taxonomy_name:join:/]/[term:name]

What are the URL Alias pattern replacements for taxonomy parent terms when building up Node paths?

And I know that for Drupal 8 there should be something like:

[term:parent:url:path]/[term:name]

But when I try to save pattern like that I get an error "Path pattern is using the following invalid tokens:..."

When I use "Available tokens" helper tool I don't see this "term" at all?! All I see is:

My available options

There's no a word on "join", "parent" or any other similar token.

1 Answer 1

1

Found it. Token should look like:

[node:field_structural_category:entity:parents]

It appeared (I think) after I changed reference field from multiple to accept only one value.

While it was accepting multiple values I could access first 3 elements, but not their parents. So this option is available only for single value fields. I see that lot of tokens are missing when tag reference field is set to accept multiple values. Bug or feature - can't say.

3
  • 1
    Have you tried [node:field_structural_category:0:entity:parents] for the first term parents when multiple values are allowed? It seems it should follow that logic, just choose which delta if there are more than one.
    – prkos
    Commented Jun 4, 2020 at 22:16
  • Hmm..seems to work (I'm not getting error message for that construction) but it's not available in "Available tokens" helper pop-up.
    – MilanG
    Commented Jun 5, 2020 at 6:57
  • Maybe it just needs to be added to the token suggestion list. I haven't been involved with this a lot, but maybe you can search the issues and see if anything similar is reported, or submit a new one?
    – prkos
    Commented Jun 5, 2020 at 18:40

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.