1

I have a custom token that gets the path value from a JSON field. The JSON field stores the path like this (in the database, the slashes are escaped, but I'm showing an unescaped example here):

{ "path": "a/b/c" }

Every node contains this JSON field, so I made a custom token, [mymodule:json_path].

I then set this token as the path for nodes on the PathAuto patterns page (/admin/config/search/path/patterns).

However, PathAuto is stripping the slashes, so when I save a node, I get the path abc when I want a/b/c.

Elsewhere, when I use the token, I get the value with unescaped slashes as expected (for example, a/b/c); I know this because if I set a metatag on the node to the token, the expected value appears.

Also, if I disable Generate automatic URL alias and manually set the path to /a/b/c, then I get the expected path of /a/b/c.

So, how can I get PathAuto not to remove the slashes?

1 Answer 1

1

This can be done through the UI, at /admin/config/search/path/settings.

Scroll down to "Punctuation" at the bottom, expand it, find the Slash (/) option near the end of the list, and set it to something other than Remove.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.