If parent term url wasn't autogenerated. And children term url was generated using token [term:parents:join-path], it use wrong parent category url (autogenerated, but not real).
Imagint we have set Blog taxonomy terms URL aliases generation rule to be [term:parents:join-path]/[term:name]
And we have categories structure: "Parent Category" with URL "my-parent-category" filled by hands.
"Sub Category" we will get URL"parent-category/sub-category" but not "my-parent-category/sub-category".
So if you filled some parent category URL by hands, you would have to update each subcategory URL and nodes URLs as well (if your node URL structure use full path throw the terms)
http://stackoverflow.com/questions/24998797/drupal-pathauto-token-termpa...
Comments
Comment #1
Dave Reid[term:parents:*] defaults to all the names of all the parent terms. You are wanting the actual URL alias of the parent term itself, not all parents, which is a different token: [term:parent:url:path] I believe.
Comment #2
pshlykov CreditAttribution: pshlykov commentedAll the parents, but real aliases, not generated again for each posts and subcategory parent using it's name. When generating sub-category link parent links generated from parent category names, and they need to be generated using real parent category URL, if user makes his parent cat link "changed-cat" instead of "cat", he wants so subcategories were using that link not "cat" but "changed-cat". I think it's logic bug in that token.
Comment #3
Dave ReidPathauto has the capability to auto-alias all children terms of a parent term (see http://cgit.drupalcode.org/pathauto/tree/pathauto.module#n707) but it is disabled by default because it could *very easily* cripple sites with large amounts of taxonomy terms in a hierarchical vocabulary. If you need to re-alias all terms, I would suggest writing an update hook to regenerate all the child term aliases using Pathauto.
Comment #4
pshlykov CreditAttribution: pshlykov commentedNo, let's imagine we have filled parent cat url by hands, and only after that we will create subcategories. That token will use generated parent URL, not that one we have provided. I understand that it won't regenerate subcategories that already present. That is another thing.
Comment #5
Dave ReidThe token uses whatever URL alias that term has, whether it was generated by Pathauto, or set manually. Please give it a try.
Comment #6
pshlykov CreditAttribution: pshlykov commentedAre you talking about [term:parents:join-path], are you sure? (i was trying yesterday, and after that i have created that question) I don't need [term:parent:url:path] because i need URL including all term parents, as i wrote, not only direct one parent.
Comment #7
Dave Reid[term:parents:join-path] will not give you the expected result you are looking for if you have set a parent term's URL alias manually. This is why I recommended in comment #1 to use [term:parent:url:path].
Think about this for a little bit here. Let's say your taxonomy term pattern in [term:parent:url:path]/[term:name].
root-term
.root-term/first-child
.root-term/first-child/second-child
.Comment #8
MacSim CreditAttribution: MacSim commentedSorry to dig up that old issue but I do agree with pshlykov.
That token is not working as expected even in Drupal 8!
I am gonna use what Dave Reid said in #7 but I was expecting that [term:parents:join-path] token to build the correct path using the parents URL alias whether or not it was manually created...
Either the description of the token is wrong or it's just not working as expected.
Anyway there's something to do here.
Comment #9
MacSim CreditAttribution: MacSim commentedComment #10
BerdirNo, it is working exactly as defined.
I think the path in join-path is confusing you. That just means that it combines together the list of values that it receives with a "/", it is *not* the path of the parents. :parents gives you internally a list of all the parent *names*, then that's combined into a string with /.
Comment #11
MacSim CreditAttribution: MacSim commentedYep it is confusing ! I guess the name of the token is not good. When I read "join-path" I am not expecting it to work as a "join-name"
And I think we should definitively have a token giving that [term:parent:url:path]/[term:name] value.
Comment #12
MacSim CreditAttribution: MacSim commentedSorry I didn't reloaded the page before to submit the form again
Comment #13
websiteworkspace CreditAttribution: websiteworkspace commentedThe following token set will generate the full URL that the original poster was looking for:
[term:vocabulary]/[term:parents:join-path]/[term:name]
Each of these tokens works as defined and expected.
The original poster didn't seem to know about the existence of [term:vocabulary] to provide the top level of the URL.
Comment #14
websiteworkspace CreditAttribution: websiteworkspace commented@ Dave Reid
There isn't any such token as the following token:
[term:parent:url:path]
The complete set of available tokens can be perused at
{site}/admin/help/token
on any D7 or D8 site.
The workable solution on both D8 and D7 is:
[term:vocabulary]/[term:parents:join-path]/[term:name]
or
[term:vocabulary:name]/[term:parents:join-path]/[term:name]
--
Parenthetically, D8.x does not implement as much functionality for taxonomy tokens as exists in D7.x.
One of the important features that is mission is functionality similar to the above, when using a reference field from within a node.
For example the following token construct exists and works in D7, to produce a complete URL to a node with a URL in a hierarchy of node/content categories:
[node:field-taxonomy-content-category:vocabulary]/[node:field-taxonomy-content-category:parents:join-path]/[node:field-taxonomy-content-category:name]/[node:title]
However, the following token type, with the - parents:join-path - construct, is missing in D8, which is a serious problem.
It is a seriously troublesome D8 feature omission.
[node:field-taxonomy(insert-name):parents:join-path]
Comment #15
Chris CharltonI've seen `parents:join-path`.
Comment #16
posmishka CreditAttribution: posmishka as a volunteer commentedHi,
I've found these patterns working for Drupal 8
It was strange that only standart field_category appeared in path.
The custom field_news_category created for custom content type (but linked to the same taxonomy) didn't worked.
Comment #17
JioJio CreditAttribution: JioJio commented#13 worked for me.
Thanks
Comment #18
alejo-moreno CreditAttribution: alejo-moreno at CodeLar commented@macsim you can get your expected result by creating two patterns:
First pattern for taxonomy terms:
[term:parents:join-path]/[term:name]
Second pattern for content:
[node:{name_of_the_field_taxonomy_term}:entity:url:path]/[node:title]
Remember to check
"Generate automatic URL alias"
for taxonomy termComment #19
nravens CreditAttribution: nravens commentedIn Drupal 9, I created a Taxonomy Term pattern [term:parents:join-path]/[term:name] but it doesn't create the full URL string beyond two terms.
I don't want to include the vocabulary in the string. The token pattern I mentioned does this:
parent/child1
If there's a child2 it does this:
child1/child2
What I want is parent/child1/child2
If I use [term:parents]/[term:name] it does this:
parent-child1/child2
Is this a bug or am I doing something wrong?