Menu path in Pathauto
Solution 1
Just an update in case anyone comes across this with a more recent version of Pathauto/Token. This worked for me:
[node:menu-link:parents:join-path]/[node:menu-link]
Solution 2
[node:menu-link:parent:url:path]/[node:title]
If the node is not in the menu, then it does not create an alias. Otherwise this seems to work for n-tier menus.
Solution 3
I think it has to be this pattern now:
[node:menu-link:url:path]/[node:menu-link]
"path" instead of "alias"
Solution 4
You'll need to install the contrib Token module as well -- although a lot of the features of Token are part of core in D7, some of the edge case tokens (like the full menu path of a given node) aren't provided by core automatically.
With that installed, I believe that [node:menu-link:parent] or [node:menu-link:parent:url] should work.
Solution 5
The pattern that works for me is the following:
[node:menu-link:parent:url:alias]/[node:menu-link]
I also intalled the Token module like Eaten suggested. Don't know if [node:menu-link:parent:url:alias]
is part of core or lives in contrib.
Related videos on Youtube
dantz
Updated on August 30, 2020Comments
-
dantz about 3 years
How do I get pathauto under Drupal 7 to generate a URL alias by the full menu path?
-
dantz almost 13 yearsUnfortunately none of these tokens do what I want. First one gives me only the parent but if a Menu-Item is on the third level the first one will be missing. And the last one gives the absolute path to the parent node.
-
asiby over 11 yearsUsing [node:menu-link:parent] or [node:menu-link:parent:url] is not a good solution. We ran into cascading issues where node aliases were being badly named because the parent menu was not named properly. And these tokens do not calculate the full menu tree leading to the node being saved. You have to really fix the parent item of a menu item in order to see any change.
-
Mario Awad over 11 yearsWorks perfectly for me. Thank you. Just in case anyone is wondering, I'm using Drupal 7.14, Pathauto 7.x-1.1, and Token 7.x-1.1 (The latest versions as of 2012-07-16). Cheers.
-
raam86 about 11 yearsThere should be some more meat to this answer
-
spatical over 9 yearsIn case the node is not added to a menu. I prefer using the node title as the final segment/token. This will prevent the node from having no url alias if forgotten: [node:menu-link:parents:join-path]/[node:title]
-
AlxVallejo about 9 yearsAlso note that the join-path of the parents refers to the title of the parent and not the url. So this could cause conflicts if you change the title of the parent and then create the alias of the child.
-
AlxVallejo about 9 yearsThis grabs the un-aliased parent path