Hello,
I'm trying to create menu entries with parents paths on URL, using a pattern like [node:menu-link:parents:join-path]/[node:title], to achieve something like:
Parent one > Parent Two > New Page = /parent-one/parent-two/new-page
Also, I set on "Settings > Punctuation" section to replace slash by separator (dash, in my case), to avoid creating a wrong URL for cases when title has a slash, for example:
Title: New/Current Page
I want to generate: /new-current-page
Instead of: /new/current-page
Both settings work fine separately. However, patterns using tokens with parents:join-path have an unexpected (and I don't believe it's unexpected only for me) replacement of slash between parents paths if above punctuation setting is configured. What I have is:
Parent One > Parent Two > New/Current Page = /parent-one-parent-two/new-current-page
But I expected: /parent-one/parent-two/new-current-page
I believe the slash replacement by separator should occur only in each specific path level, but not on the result of parents:join-path. I understand that I am "intentionally" setting to replace slash by separator, but it's very unlikely one would like to do it on the separator that joins parents paths.
I tried different settings to achieve the correct result, but I couldn't figure out a consistent solution without using settings above. Is this a bug? Is there another way to work around that?
Thank you.
Regards,
Mauricio
Comments
Comment #2
jacobfrancke@gmail.com commentedI'm having similar behaviour.
What i'm trying to do is the following.
I have a view which displays nodes. The view is (navigational) a child of a node. So for the view I have the following url: http://www.example.com/node/view
Both node and view are in the main navigation.
Now when I create a page 'node-2' and I add it in the main navigation below 'view', I get the following url: http://www.example.com/nodeview/node-2
Tested this with: [node:menu-link:parent:url:relative]/[node:title] and [node:menu-link:parent:url:path]/[node:title]. Both seem to behave like this.
Am I doing something wrong or could this be a bug in pathauto or maybe token?
Regards,
Jacob Francke
Comment #3
jacobfrancke@gmail.com commentedJust fixed the problem by configuring the safe tokens as described in:
https://www.drupal.org/project/pathauto/issues/3006242#comment-12840863
Comment #4
maursilveira commented@jacobfrancke This is very useful, and worked perfectly for me! Thank you for researching and posting here this solution. Personally, I didn't know exactly how Safe Tokens work. Documentation about Safe Tokens is very scarce, what is unfortunate due to how handy it is.
Although I still think Pathauto shouldn't replace separator `/` from parents menu path, this seems a fine way to solve the issue.
Comment #5
berdirPathauto needs to know which tokens are allowed to have / and which don't. If you create a node that has a / in the title it shouldn't appear in the alias.
It should have sane defaults, if your config didn't then you might have overwritten it with config import on update, as many others did.
Comment #7
2pha@JacobFrancke thankyou, the site I am working on had nothing in "safe tokens"