I have a site setup with 'hackable' urls, meaning that removing one part of the url will reveal the parent page's content. For example:

golf - overview of golf content
golf/course-2/ - overview of course two content
golf/course-2/hole-3 overview of course 2, specific hole 3. - you get the idea

Using the token [node:menu-link:parent] I can successfully achieve what I am looking for when a menu is only 1 level and 2 levels deep. However, 3 level deep gives me (using the above example) course-2/hole-3 when what I need the alias to actually be is golf/course-2/hole-3.

Perhaps I am not using it correctly. What configuration should I use to get the entire menu path as part of my url alias? Also, it needs to be dynamic so that if a user adds another menu item, 4th level, or whatever, things will fall into place. Thanks for the help!

CommentFileSizeAuthor
#11 menulink.png76.9 KBbones
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dave Reid’s picture

Status: Active » Fixed

You should use the token [node:menu-link:parent:url:path] which gives you the full alias of the parent menu link.

davidee’s picture

This doesn't work for me. I work with Node Hierarchy. I have it like this:

A = first level link
[node:menu-link:parent:url:path]
B = second level link
[node:menu-link:parent:url:path]
C = third level link
[node:menu-link:parent:url:path]

Am I doing something wrong?

davidee’s picture

Status: Fixed » Active
Dave Reid’s picture

Status: Active » Fixed

Then you probably want something like [node:nodehierarchy:parent:url:path] but I cannot give out much help for things out of scope of the Token module issue queue (modules that provide other tokens).

davidee’s picture

Oke thank you!

davidee’s picture

It worked:) I am very happy!

Gastonia’s picture

Hey, that worked great for me, thanks a lot!

Gastonia’s picture

This note is off topic, but while we are on the subject, you guys may know of a solution. The next logical step for me after getting this to work is to make my breadcrumb links exactly mimic the same structure. Can anyone recommend how to do that or what to put into the template.php file? I used taxonomy menu to create my menu structure. Everything is working great except for the breadcrumbs which just say 'home'

Thanks!

sheena_d’s picture

@Gastonia: checkout the Custom Breadcrumbs module: http://drupal.org/project/custom_breadcrumbs

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

bones’s picture

Title: Url alias tokens - Menu Parent: How do I get the full menu path as the URL Alias structure? » Token [node:menu-link:parent:url:path] not listed in replacement patterns
Category: support » bug
Status: Closed (fixed) » Active
FileSize
76.9 KB

This works for me, but why isn't it in the list of Tokens? See attached screenshot.

[node:menu-link:parent:url:path] is a very useful token for creating path aliases based on the menu, and should be listed.

Dave Reid’s picture

Title: Token [node:menu-link:parent:url:path] not listed in replacement patterns » Url alias tokens - Menu Parent: How do I get the full menu path as the URL Alias structure?
Category: bug » support
Status: Active » Fixed

If you upgrade to Pathauto 7.x-1.x-dev (not 7.x-1.0) you'll be able to use [node:menu-link:parents:join-path] which is what replaced the recommendation in this issue.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

BrianLewisDesign’s picture

Title: Url alias tokens - Menu Parent: How do I get the full menu path as the URL Alias structure? » [node:menu-link:parent:parent:parent:parent:url:path]/[node:title]

[node:menu-link:parent:url:path]/[node:title] -- this repeats the top level parent multiple times, for nth children in the menu. makes a mess. doesn't get the full heirarcy.

[node:menu-link:parent:parent:parent:parent:url:path]/[node:title] -- this gets the top parent only, with no repeats, down to the 4th child in the menu.

[node:menu-link:parents:join-path]/[node:title] -- perfect. this gets the whole parent menu hierarchy into the URL. that's what i was after.

caschbre’s picture

[node:menu-link:parents:join-path]/[node:title] -- perfect. this gets the whole parent menu hierarchy into the URL. that's what i was after.

I know this is an old issue but for anyone looking for a solution... the above doesn't work perfectly. See #1496582: Manually set parent item is not included in path.

Basically the above token uses the parent items "menu title" and not the node path. So if a manual path was set on an ancestor node or if the node title varies from the menu title on any of the ancestor nodes then the url won't come out as expected.

jelo’s picture

Issue summary: View changes

[node:menu-link:parents:join-path] works very well. Is there an option to limit the depths of the parent links to prevent super long URLs?
Example: [node:menu-link:parents:join-path/3] -> for three levels deep?

Justincletus’s picture

Try this pattern for menu and submenu item
[node:menu-link:parents:join-path]/[node:title]

nessthehero’s picture

Apologies for bumping, but I have a question and it involves this token.

[node:menu-link:parent:url:path]/[node:title] is working in a Drupal 8.8 site as of March 10, 2020.

My question is that this token, [node:menu-link:parent:url:path], does not appear as an available token on the interface that shows all available tokens. This can be seen at /admin/help/token/.

I can find [menu-link:parent:url:path] and [node:menu-link:url:path], but nothing under the parent. It stops at [node:menu-link:parent:url].

Is this an issue with Pathauto or an issue with Token?

I realize the token is working, but it's disingenuous, confusing, and unhelpful to future users and "people not us" for this to not be documented.