Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When using the path token for a nodereference value, the output link begins with two forward slashes
Title:
[field_project-title-raw]
Path:
[field_project-path]
Resulting link:
//projects/53
I 'fixed' this in my instance by preceding the token with a period, so that the path is "/./projects/53"
Comment | File | Size | Author |
---|---|---|---|
#3 | double_slash_fix_61.diff | 731 bytes | MGN |
#3 | double_slash_fix_62.diff | 860 bytes | MGN |
Comments
Comment #1
MGN CreditAttribution: MGN commentedThese kinds of problems are usually due to the specific token, and the module that creates them, unless you see it happening all the time (with or without tokens).
Custom breadcrumbs just uses the value returned by the token, it doesn't create it or modify it, so if one token type is acting up, there is probably a problem in the module that is providing the token.
What version of cck are you using, and have you checked the issue queue for cck on this?
Comment #2
gappleI did some code digging, as I use the same token for a couple of Pathauto aliases but didn't have the same issue with double forward slashes appearing.
It looks like the CCK token returns the path with an initial forward slash, and custom_breadcrumbs_nodeapi() through l() and url() will always prepend a forward slash to the path, resulting in the initial double slash.
Pathauto performs some cleanup of the generated aliases to ensure this doesn't happen:
pathauto.inc
I also thought more about my preceding period fix, and while it will work for anyone with drupal installed at root, it could cause problems otherwise. I think the result would be "/{subfolder}/./{subfolder}/projects/53" which would resolve to the path /subfolder/subfolder/project/53
Comment #3
MGN CreditAttribution: MGN commentedThanks. I've used the snippet above to collapse a double slash to a single slash. The patches below are rolled against 6.x-1.x-dev (double_slash_fix_61.diff) and 6.x-2x-dev (double_slash_fix_62.diff). I would appreciate it if people using the [field_*] cck tokens could test and make sure that this doesn't cause any unanticipated problems.
Thanks
Comment #4
Martynov-1 CreditAttribution: Martynov-1 commentedHello,
I installed the patch manually and tested it. But it still doesn't work. And again the module ignores [site-url] placeholder token in "Paths" field but works well with it in "Titles" field. Maybe I did something wrong because this is the first patch in Drupal that I installed. Therefore additional testing is needed.
Comment #5
MGN CreditAttribution: MGN commentedI didn't add the code to trim the leading slash. Since you are patching manually, can you just add one more line to the _custom_breadcrumbs_create_crumb function? It should read
I can post a real patch if you like, but this might be just as good for now.
Comment #6
Martynov-1 CreditAttribution: Martynov-1 commentedThank you very much! Now it works!
Comment #7
MGN CreditAttribution: MGN commentedThanks for testing. Committed to 6.x-1.x-dev and 6.x-2.x-dev.