Closed (fixed)
Project:
Pathauto
Version:
7.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Feature request
Assigned:
Reporter:
Created:
26 Nov 2007 at 07:54 UTC
Updated:
24 Aug 2010 at 13:50 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
gregglesI 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.
Comment #2
groenm commentedI 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.
Comment #3
gregglesAssigning to myself to indicate I want it done for 5.x-2.1.
Comment #4
drpitch commentedGreat!
Comment #5
bobdalob commented+1
Comment #6
gregglesSorry for leaving my name on this. I re-prioritized and don't have time for this now.
Comment #7
cs8c commentedAnyone working on this? I hate the forward slash being removed, would love the option to choose to the regular separator instead.
Comment #8
xxvelcrar commentedI'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 :-)
Comment #9
xxvelcrar commentedComment #10
gregglesThe 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!
Comment #11
abv commentedThis 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);
Comment #12
greggles@abv - Works great for termpath/catpath - but not for bookpath etc.
Comment #13
mike_r1977 commentedIt'd be a great feature for Drupal 6 as well.
Comment #14
joshuajabbour commentedHere'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...
Comment #15
markj commentedI 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
Comment #16
müzso commentedJoshua'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:
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.
Comment #17
müzso commentedI'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 ...
Comment #18
Frank Steiner commentedI 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...
Comment #19
rcross commentedbump.
Any updates on this being included in the next release? Or someone else testing the patch?
Comment #20
Anonymous (not verified) commentedA 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?
Comment #21
Anonymous (not verified) commentedSorry, 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.
Comment #22
Anonymous (not verified) commentedComment #23
k3vin commented+1
Comment #24
seancr commentedThis works with custom tokens too; add "path" in the token name if you want to keep your forward slashes.
Comment #25
mizerydearia commentedIs there a solution to this issue yet?
Comment #26
traviscarden commentedSubscribe
Comment #27
drpitch commentedBump
Comment #28
gregglesHas menutrails been fixed yet?
Comment #29
dcasey commentedI'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/childI'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.
Comment #30
bobzillaforever commentedThe solution I found for #29 was on line 452:
I'm not sure if there was a reason
drupal_substrwas being used, whenstrposseemed to accomplish the task quite nicely....drupal_substronly looks at the ends of the strings, but we needed to find "path" wherever it was--strposallowed for a trailing :vid.Comment #31
fixus971 commentedHi 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
Comment #32
ManyNancy commentedSo does anyone know how to remove the /slash from terms titles without affecting term paths?
Comment #33
dave reid@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.
Comment #34
traviscarden commented@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 ofblog/categories/love-hate). Does that clear things up at all?Comment #35
dave reid@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?
Comment #36
ManyNancy commented@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.
Comment #37
dave reid@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.
Comment #38
traviscarden commented@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.
Comment #39
dave reid@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.
Comment #40
dave reidMarked #728276: Add slash to array of punctuation values as a duplicate of this issue.
Comment #41
dave reidComment #42
drpitch commented@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 :)
Comment #43
ManyNancy commentedI'm ok with node title slashes being removed. My problem was that term titles did not have slashes removed.
Comment #44
-enzo- commentedHello 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
Comment #45
tuffnatty commentedsubscribing
Comment #46
aleksey.tk commentedsubscribing
Comment #47
anrikun commentedsubscribing
Comment #48
dave reidComment #49
sirclickalotI 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
Comment #50
dave reid@SirClickALot: Name your token with a '-path' or '-url' suffix and it will be treated like an URL and not have slashes removed.
Comment #51
dave reidComment #52
dave reidDue 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
Comment #53
traviscarden commented[stupid question removed] :-P
Comment #54
dave reidYep 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.