Problem/Motivation

I'm having a strange problem where pathauto patterns aren't generating parent menu items. I've got a url alias pattern set up [node:menu-link:parent:url:path]/[node:title] and Drupal 9.1.4 won't add the parent path to the url alias. When I set it up on a fresh Drupal 9 site, it works as expected.

The reason I put the issue here and not in the pathauto issue queue is that I can put placeholders in the pathauto pattern such as /pre/[node:menu-link:parent:url:path]/post/[node:title] and the placeholders show up fine. Also when I look in the "Browse available tokens" I don't see menu link option at all which seems very suspicious:

browse tokens failing

On my test site, you see the token appearing:

browse tokens working

Steps to reproduce

1. setup pathauto pattern [node:menu-link:parent:url:path]/[node:title]
2. create a node and add it to main menu (e.g. title: page1)
3. create another node and add it as a child to the menu e.g. page2
4. You expect page2 url alias be page1/page2 but instead the url alias is page2

I'm glad to go hunting for the culprit so any suggestions would be welcome. I'll be stepping thru token code and see if I can find anything. I know it is somewhat unrelated, but I tried the patch at https://www.drupal.org/files/issues/2021-01-14/pathauto-update_child_ali... but that had no effect.

CommentFileSizeAuthor
browse_tokens2.png77.33 KBselwynpolit
browse_tokens.png59.28 KBselwynpolit

Issue fork token-3197725

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

selwynpolit created an issue.

selwynpolit’s picture

I'm curious if anyone has seen anything like this. I guess I'm going to dive into the token module and start debugging through anything that looks like menus. Suggestions are welcome ;-)

fly2ganesh’s picture

@selwynpolit, followed steps mentioned in the description with
Drupal 9.1.4
pathauto 8.x-1.8
token 8.x-1.9
I am getting expected page2 URL alias as page1/page2

cb’s picture

This is an old issue but I'm getting this with Drupal 9.5.9 at the moment using the same token [node:menu-link:parent:url:path] - it simply will not show parent url path - i only ever get the child node in the path.

I'm hoping its an easy fix. :)

EDIT: Update to 9.5.10 fixed this problem.

nicxvan made their first commit to this issue’s fork.

ed2908’s picture

I'm not seeing this token in the list of available tokens using 8.x-1.15 in Drupal 10.3.2

When I enter [node:menu-link:parent:url:path] into my pattern, it's simply ignored.

Edit:

I looked at the parent node and saw it had been added to the menu through the menu, so I removed that link and re-added it from the node edit interface. Then, [node:menu-link:parent:url:path] suddenly started working for the child menu items. It's possible I changed something somewhere else to get it to start working again, but I don't think I made any other changes.

tjhellmann’s picture

Switching to [node:menu-link:parent:url:relative] allowed the url to be created when the link is added through the menu interface. Wanted to add here in case it's helpful for anyone else as a workaround.