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

Rob_Feature’s picture

Issue summary: View changes

Oops, realized just now that ALL slashes in the group relative path token are missing...updated issue.

Rob_Feature’s picture

Status: Active » Closed (works as designed)

Darn. Looks like this was a token issue. Updated to dev and it's all better. Closing.

loopduplicate’s picture

Priority: Major » Normal
Status: Closed (works as designed) » Active

Even 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

shushu’s picture

Status: Active » Postponed (maintainer needs more info)

@jeff, @bob, is it the same issue, or a separated issue ?

loopduplicate’s picture

@shushu The issue I'm having is exactly the same as in the description. Cheers, Jeff

loopduplicate’s picture

Status: Postponed (maintainer needs more info) » Active
shushu’s picture

Project: Organic groups » Pathauto
Version: 7.x-2.x-dev » 7.x-1.x-dev
Component: og.module » Code
Status: Active » Needs work

Gotcha :-)
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 ?

loopduplicate’s picture

@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

shushu’s picture

@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.

loopduplicate’s picture

@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

Dave Reid’s picture

Yes, I would highly recommend using url:path instead of url:relative in tokens in Pathauto patterns.

loopduplicate’s picture

Thanks for your feedback, Dave :)

TMHD’s picture

Hi,

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.

leymannx’s picture

Thanks a lot #13. Disabling slash removal finally fixed my custom join path from node fields.

jimkeller’s picture

Adding 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.

Berdir’s picture