Hello,

In 5.x-1.x version, when I used a forward slash in title nodes, pathauto replaced it by separator character.
But in 5.x-2.x version, forward slash is always removed. There's no way to tell what you want to do with that slashes (forward slash character is not included in the punctuation control area)

For example, how can I make a forward slash is replaced by the separator character?

Thanks.

Comments

greggles’s picture

Title: Forward slashes always removed » provide control over forward slash character
Category: bug » feature

I agree that the admin should have control of this.

The trick is that all strings are passed through the same cleaning function, so pathauto has to be smart about whether or not it strips out the forward slash when it is dealing with termpath or bookpath etc.

groenm’s picture

I second this.

Removal of the slashes results in undesirable "glueing" in URLs. It would be much appreciated, if the slashes would be replaced by another character, instead of simply being removed.

greggles’s picture

Assigned: Unassigned » greggles

Assigning to myself to indicate I want it done for 5.x-2.1.

drpitch’s picture

Great!

bobdalob’s picture

+1

greggles’s picture

Assigned: greggles » Unassigned

Sorry for leaving my name on this. I re-prioritized and don't have time for this now.

cs8c’s picture

Anyone working on this? I hate the forward slash being removed, would love the option to choose to the regular separator instead.

xxvelcrar’s picture

StatusFileSize
new1.11 KB

I've put together a trivial patch that fixes this for the 2.2 release. Hopefully that pokes this enough to get this ticket closed in some manner :-)

xxvelcrar’s picture

Status: Active » Needs review
greggles’s picture

Status: Needs review » Needs work

The problem with this approach is that it doesn't work for people who use termpath nor catpath nor termalias nor bookpath (etc.)

Thanks for the idea, though!

abv’s picture

This is what I changed on lines 235 and 236 so that my taxonomy paths looked good when there was a slash in the term names. You could do something similar.

$values[$label .'path'] = $catpath .'/'. check_plain(preg_replace('/\//', '', $category->name));
$values[$label .'path-raw'] = $catpath_raw .'/'. preg_replace('/\//', '', $category->name);

greggles’s picture

@abv - Works great for termpath/catpath - but not for bookpath etc.

mike_r1977’s picture

joshuajabbour’s picture

Version: 5.x-2.x-dev » 7.x-1.x-dev
StatusFileSize
new1.97 KB

Here's a new patch for 6.x that adds in the ability to replace forward slashes. In my (limited) testing, it handles the special cases for menu and taxonomy paths (my changes just piggyback on the code that already skips replacement of slashes in those cases). Please test and let's get this into the next release...

markj’s picture

I agree, this is important functionality.

Applying the following to Path Auto 6.x-2.x-dev fails:

patch < pathauto-slash-replacements.patch
patching file pathauto.inc
Hunk #1 succeeded at 192 with fuzz 2 (offset 51 lines).
Hunk #2 FAILED at 204.
Hunk #3 succeeded at 468 (offset -3 lines).
Hunk #4 succeeded at 553 (offset 51 lines).
1 out of 4 hunks FAILED -- saving rejects to file pathauto.inc.rej

müzso’s picture

StatusFileSize
new1.57 KB

Joshua's patch was not made based on current HEAD version of pathauto.inc. I've fixed that.
Also fixed another bug: Joshua deleted the original slash removing code.
I mean this one:

  // If something is already urlsafe then don't remove slashes
  if ($clean_slash) {
    $output = str_replace('/', '', $output);
  }

However with his patch if the function gets $clean_slash=TRUE parameter and the punctuation rule for slashes is set by the user as action=2 (no action, do not replace), then slashes will be kept in the string, which is wrong (since the function parameter $clean_slash has to be favoured over user's setting for slash handling).

I've fixed this one too (by putting back the original slash replacer code) and attached revised patch. Of course the fix could have been done differently too, but this seemed to be the better choice.

müzso’s picture

Status: Needs work » Reviewed & tested by the community

I've changed the status to "reviewed and tested".
I'm not sure whether a single review+test is sufficient for this status change, but unfortunately this patch did not get much attention from anyone else in recent months and I don't think we should wait another 3-4 months til someone else tests it too ...

Frank Steiner’s picture

I don't think that $clean_slash should have precedence. $clean_slash is set to FALSE for e.g. menupath or menupath-raw. But if I *want* the slash to be replaced, it *should* be replaced. Otherwise the patch gives not really any control to most situations...

rcross’s picture

bump.

Any updates on this being included in the next release? Or someone else testing the patch?

Anonymous’s picture

A small addition, I see a strange difference in handling "/" slashes from different other modules (without patches):

- [menupath-raw] (in token_node.inc in the token module) has "/" slashes that are NOT stripped
- [menu-trail-parents-raw] (in menutrails.module in the menutrails project) has "/" slashes that ARE stripped

How is this possible? Why aren't token module's own tokens stripped from slashes, but others are?

Anonymous’s picture

Status: Reviewed & tested by the community » Needs work

Sorry, but the latest patch from #16 does not help preventing slash / removal from the [menu-trail-parents-raw] token from menutrails.module:

1. [menu-trail-parents-raw] contains for example "Solutions/Ecommerce", I checked the $tokens['menu-trail-parents-raw'] = implode('/', $trail_raw); - its good
2. Using patch from #16, slashes / still being removed from [menu-trail-parents-raw]
3. Using patch from #16, now with setting / to "no action", but slashes STILL removed

No effect from the patch, because the culprit is in:

function pathauto_clean_token_values($full) {
...
return $full->values;
}

This function strips all slashes from all tokens that are not "path", "path-raw" or "alias". So what would be the solution? I shall instruct menutrails people to call their tokens something else, with -"path" included.

Anonymous’s picture

Status: Needs work » Reviewed & tested by the community
k3vin’s picture

+1

seancr’s picture

This works with custom tokens too; add "path" in the token name if you want to keep your forward slashes.

mizerydearia’s picture

Is there a solution to this issue yet?

traviscarden’s picture

Subscribe

drpitch’s picture

Bump

greggles’s picture

Has menutrails been fixed yet?

dcasey’s picture

I'm having similar issues with the Hierarchical Select module (6.x-3.x-dev), Pathauto (6.x-1.1), and Token (6.x-1.12).

Using token: [save-lineage-termpath-raw:vid] I get a hyphen separating terms: parent-child

So, in template.php I set: variable_set('hs_taxonomy_separator', '/'); It is joining the terms together without the / (slash): parentchild NOT parent/child

I've also tried hacking the hs_taxonomy.module and setting: $separator = '/'; with same results.

How do I put the slash between the terms? It seems Pathauto keeps dropping it.

bobzillaforever’s picture

StatusFileSize
new914 bytes

The solution I found for #29 was on line 452:

if (drupal_substr($full->tokens[$key], -4, 4) === 'path' || drupal_substr($full->tokens[$key], -8, 8) === 'path-raw' || drupal_substr($full->tokens[$key], -5, 5) === 'alias') {
if (strpos($full->tokens[$key], 'path') !== FALSE || strpos($full->tokens[$key], 'alias') !== FALSE) {

I'm not sure if there was a reason drupal_substr was being used, when strpos seemed to accomplish the task quite nicely.... drupal_substr only looks at the ends of the strings, but we needed to find "path" wherever it was--strpos allowed for a trailing :vid.

fixus971’s picture

Hi all. I updated all at 20/122009 but can't found a method to convert some as:
Ex: "bag/hat" that now is converted to "baghat": bad for SEO.. I want 2 words separated by "-".
I'm not found punctuation settings option for exchange slash "/" from node title.
I simply want to splint words in resulting url alias.
Thanks 4 info

ManyNancy’s picture

So does anyone know how to remove the /slash from terms titles without affecting term paths?

dave reid’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
Status: Reviewed & tested by the community » Needs work

@ManyNancy: That is now how the term path tokens work now in the latest code.

Unless we can get a clear definition of what is the problem and how to fix it (which I can't get from reading all this issue's replies), plus a detailed list of how to reproduce the problem in order to write a test to make sure it doesn't get broken again, I don't think we'll be able to get this fixed in the next release.

traviscarden’s picture

@Dave Reid: My understanding of the issue, Dave, (or at least my interest in it) is that if you have a node title or a taxonomy term with a slash in it (e.g. "Love/Hate"), Pathauto will leave that slash in path aliases based on it, giving the false appearance of a directory structure (e.g. blog/categories/love/hate). The desirable behavior, of course, would be to be able to define how a forward slash is handled the same way we do other punctuation and special characters—by specifying via the UI whether and with what to replace it (e.g. with a dash, so that the afore-mentioned example would result in an alias of blog/categories/love-hate). Does that clear things up at all?

dave reid’s picture

@TravisCarden: Ah, we actually fixed that with another issue for removing slashes on an individual taxonomy term. :)

Is there anything else to this or should I just mark it as fixed then?

ManyNancy’s picture

@Dave Reid, is that in 6.1.x or 6.2.x or both? Should I use the dev version if I want this feature?

Thanks.

dave reid’s picture

@ManyNancy: It's currently in all branches of the module. If you're going to be using a D6 version, I'd recommend using the 6.x-1.x-dev release.

traviscarden’s picture

@Dave Reid: Thanks, Dave. Did the fix you refer to above (#36) also treat node titles containing slashes? In order to mark this issue as fixed, I think we need to make sure we've handled every class of automated aliases: terms, nodes, and users.

dave reid’s picture

@TravisCarden: Actually now that I went and checked this more I realized we're now running taxonomy terms through pahtauto_cleanstring() but that we're still removing the forward slash. I'm working on a solution for 6.x-1.x and 7.x-1.x to get this fixed once and for all, plus tests to back it up.

dave reid’s picture

Marked #728276: Add slash to array of punctuation values as a duplicate of this issue.

dave reid’s picture

Assigned: Unassigned » dave reid
drpitch’s picture

@Dave Reid: Yes, that's what is actually happening to me. I create a node title containing forward slashes and pathauto removes them.

Example:
Node title: 2/3 times a week
Pathauto link: 23_times_a_week

I think that forward slash should be handled the same way we do other punctuation and special characters in the module UI.

I hope this helps to get a clear definition of what is the problem :)

ManyNancy’s picture

I'm ok with node title slashes being removed. My problem was that term titles did not have slashes removed.

-enzo-’s picture

Hello Bobzillaforever

Thanks a lot for your solutions, I apply and works like a charm.

I expend like 8 hours research in hierarchical select until I found your solution.

Thanks so much.

Please apply this path.

enzo

tuffnatty’s picture

subscribing

aleksey.tk’s picture

subscribing

anrikun’s picture

subscribing

dave reid’s picture

Priority: Normal » Major
sirclickalot’s picture

I might be missing something crucial here but can I take step back and suggest that we simply be given control over whether or whether or not to strip out '/' characters in tokens per se.

Why can't we have the same control over these as we do with other characters such as '&' etc. ?

Personally, I REALLY need to be able to make up tokens which are psuedo URLs like this...

...home/child-1/grandchild-1/great-grandchild-1

but I need to do it in a SINGLE TOKEN because I cannot pre-determine how deep the tree is going to be.

What I really do not want to see this reduced to...

...home/child-1grandchild-1great-grandchild-1

or indeed anything else replacing the '/'

Any offers of advice on how I might achieve this given that pathauto insists on stripping the slashes out of my lovingly constructed tokens!

Thanks

dave reid’s picture

@SirClickALot: Name your token with a '-path' or '-url' suffix and it will be treated like an URL and not have slashes removed.

dave reid’s picture

Title: provide control over forward slash character » Add the (foward) slash to the list of character settings
Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Needs work » Needs review
StatusFileSize
new1.32 KB
dave reid’s picture

Status: Needs review » Fixed

Due to changes made previously, this really was a simple patch! Tested locally on all three branches.
http://drupal.org/cvs?commit=404554
http://drupal.org/cvs?commit=404556
http://drupal.org/cvs?commit=404564

traviscarden’s picture

[stupid question removed] :-P

dave reid’s picture

Yep it was committed to 7.x-1.x, 6.x-2.x, and 6.x-1.x. It would be super double-plus awesome if you could help test them today.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.