Using the latest version of OG. I have a group node and it's alias generates correctly based on my pathauto patterns. Then I am using the following token path for content within the group:
[node:og-group-ref:url:relative]/[node:title]
When using this pathauto token, I get a broken path. The slashes in the [node:og-group-ref:url:relative] part are removed every time. So for example if my Group path is:
firstpart/secondpart/thirdpart
my "group content" page gets the following path:
firstpartsecondpartthirdpart/group-content
Note the missing slashes in the first token. I've tried upgrading to dev and still have the problem. Marking as major since this is probably a pretty common path token that's broken.
Comments
Comment #1
Rob_Feature CreditAttribution: Rob_Feature commentedOops, realized just now that ALL slashes in the group relative path token are missing...updated issue.
Comment #2
Rob_Feature CreditAttribution: Rob_Feature commentedDarn. Looks like this was a token issue. Updated to dev and it's all better. Closing.
Comment #3
loopduplicateEven after updating OG, Token, and Entity to the latest dev releases, [node:og-group-ref:url:relative] still ended up stripping slashes. I worked around the issue using [node:og-group-ref:url:path] instead.
Reopening the bug but moving priority to normal.
Regards,
Jeff
Comment #4
shushu CreditAttribution: shushu commented@jeff, @bob, is it the same issue, or a separated issue ?
Comment #5
loopduplicate@shushu The issue I'm having is exactly the same as in the description. Cheers, Jeff
Comment #6
loopduplicateComment #7
shushu CreditAttribution: shushu commentedGotcha :-)
After debugging I found out that "[node:og-group-ref:url:relative]" does not fit to the token structure checked by pathauto_clean_token_values(), so it is being cleared.
Considering each of "path|alias|url|url-brief" might have attribute such as "relative", just patching in order to solve our current need seems to be too limited. Any idea how we should solve it generically ?
Comment #8
loopduplicate@shushu I'm going to try and dig deeper. So far, at least, here are the exact steps to reproduce:
Install fresh D7 site, then:
drush dl og pathauto token entity entityreference views_bulk_operations ctools views --dev --destination=sites/all/modules/contrib -y;
drush en entity_token og_ui pathauto -y;
drush dis overlay -y;
drush cc all;
Make Article a group type
Make Basic page a group content type
Set the Maximum number of values users can enter for og_group_ref to 1
Set the Basic page pathauto pattern to be: [node:og-group-ref:url:relative]/page/[node:title]
Create an Article called "test group"
Create a Basic Page called "test group content"
Notice the url for the basic page is: contenttest-group/page/test-group-content
Comment #9
shushu CreditAttribution: shushu commented@loopduplicate, I think the direct solution is simple. In pathauto.inc change line #607 to:
if (!preg_match('/(path|alias|url|url-brief|relative)\]$/', $token)) {
and this should solve the problem. You can try this out.
What I am saying, though, that this might not be the right solution, since it covers only the specific case.
Comment #10
loopduplicate@shushu I already worked around this bug for my use case by using [node:og-group-ref:url:path] instead. I don't need a 'direct solution'. :) I meant that I will try and take a closer look at everything later and try to come up with a patch that can be committed to whatever projects make sense. I only have a small amount of free time every day so I have to just do a little bit at a time. I wrote down the steps to reproduce because I don't know when I'll get back to this bug. For anyone else running into this who needs a hotfix, thanks for the 'direct solution' above. :)
Cheers,
Jeff
Comment #11
Dave ReidYes, I would highly recommend using url:path instead of url:relative in tokens in Pathauto patterns.
Comment #12
loopduplicateThanks for your feedback, Dave :)
Comment #13
TMHD CreditAttribution: TMHD commentedHi,
Refering to the "When using this pathauto token, I get a broken path. The slashes in the [node:og-group-ref:url:relative] part are removed every time."
Not sure if this is relevant or not but in the URL-Alias settings you can set what characters is going to be removed by path auto. There you can set "do nothing" for the character Slash (/) that way this character wont be stripped away by path auto.
Comment #14
leymannxThanks a lot #13. Disabling slash removal finally fixed my custom join path from node fields.
Comment #15
jimkeller CreditAttribution: jimkeller commentedAdding this note here since it's the relevant google search result:
For anyone who's running into an issue with tokens being stripped of slashes (and who doesn't want to blanket disable this setting), at least in Drupal 8, slashes are removed from tokens UNLESS the token name ENDS with one of the following strings:
path
alias
url
url-brief
For example, [my-special-path] will retain slashes, but [path-special] will have slashes removed.
Comment #16
BerdirThat's what #2773573: AliasCleaner preg_match for tokens is too broad is about.