Often times, we are forced to have a very long title name. When that happens, PathAuto often trunkates the path as it should, but it sometimes keeps the trailing space (and converts it to a - as it should)
Possible for PathAuto to delete the trailing slash (trailing -, when its converted)
An example url that PathAuto generates is:
http://www.example.com/press_releases/2008/05/aol-awards-ohio-university...
Steps to repeat:
1. Create a posting. For the title, give it a REALLLYYY LOOONNGGG name.
2. Submit it.
Thanks!
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | 269929_Break_alias_at_word-18.patch | 2.26 KB | greggles |
| #16 | 269929_Break_alias_at_word-15.patch | 2.21 KB | greggles |
| #12 | 269929_Break_alias_at_word-12.patch | 1.4 KB | Freso |
| #11 | 269929_Break_alias_at_word-11.patch | 1.75 KB | greggles |
| #9 | 269929_Break_alias_at_word-8.patch | 742 bytes | Freso |
Comments
Comment #1
Freso commentedI just added a lot of pattern trimming to both the 5.x-2.x and 6.x-1.x branches. Could please confirm this is still happening with the 5.x-2.x-dev version? (You may have to wait a bit though, until the "Last updated" field says "June 13" (or later).)
Comment #2
tcconway commentedHey Freso,
Just installed 5.x-2.x-dev and still having the same issue. It still creates a url that ends in "-".
Thanks.
Comment #3
gregglesSteps taken:
1. Create a node with the title
Often times, we are forced to have a very long title name. When that happens, PathAuto often trunkates the path as it should, bu2. Resulting alias was
often-times-we-are-forced-to-have-very-long-title-name-when-that-happens-pathauto-often-trunkates-thThat seems as expected to me.
So, I tried
1. Create a node with the title
Often times, we are forced to have a very long title name. When that happens, PathAuto often trunkates the path as it(note all of the spaces after trunkates, I expected pathauto to cut the line there and replace the space with hyphen) but...2. Resulting alias was
often-times-we-are-forced-to-have-very-long-title-name-when-that-happens-pathauto-often-trunkates-thSo I tried
1. Create a node with the title
Often times, we are forced to have a very long title name. When that happens, PathAuto often trunkates t he path as it(note the space in the middle of the word "the" in "trunkates t he")2. Resulting alias was
often-times-we-are-forced-to-have-very-long-title-name-when-that-happens-pathauto-often-trunkates-t-So, I'd say that is the bug, right?
Comment #4
tcconway commentedWell played. That's exactly what we are experiencing as well.
To me, there are two issues:
often-times-we-are-forced-to-have-very-long-title-name-when-that-happens-pathauto-often-trunkates-th. Resulting in:often-times-we-are-forced-to-have-very-long-title-name-when-that-happens-pathauto-often-trunkatesComment #5
Freso commentedHohum. I'm inclined to re-categorise into a feature request for what's described in #4. This also means that I'm inclined to not want to spend time fixing this for 5.x, but have it moved to 6.x-2.x instead.
Comment #6
greggles@Freso - Agreed.
I've also received several requests that when urls are shortened for whatever reason they should be shortened to a good logical point (i.e. separators) instead of just the exact point where 100 characters lands. Since those seem similar in my mind, I'll just bundle that one in here.
Comment #7
gregglesSomething like http://api.drupal.org/api/function/truncate_utf8 will sure help when we need to do this.
Comment #8
Freso commentedComment #9
Freso commentedThis should work, but I haven't tested it. So please do.
Comment #10
Freso commentedJust tested it, and it doesn't seem to work. Bugger.
Comment #11
gregglesHow about this?
Comment #12
Freso commentedYay! It works! :D
It had a line of pure whitespace though, so fixed that. I also added a line documenting what that block of code does. Should be good to go.
Comment #13
gregglesAwesome - thanks, Freso.
http://drupal.org/cvs?commit=131526
Comment #14
gregglesPer Freso, this needs a little more testing...
Comment #15
gregglesThe problem was that if you created a node with a short title this still lopped off the last word.
1. Create a node with the title "this is a short title"
Expect results:
aliased as content/this-short-title
Actual results:
aliased as content/this-short
The attached patch fixes that problem, generalizes this code so it can be re-used elsewhere in pathauto, and then re-uses it where individual tokens are built and shortened to the appropriate length.
Comment #16
gregglesAttached...now...
Comment #17
Freso commented+1 for separating the logic to its own function, but perhaps call it
_pathauto_truncate_url()ortruncate_charsinstead? (FWIW, the 7.x version oftruncate_utf8()will bedrupal_truncate_chars().)Also "A Pathauto friendly version of truncate_utf8" should be finished off with a ".". ;)
Apart from this, the patch looks good. Looking forward to test it in the morrow!
Comment #18
gregglesGood points.
Comment #19
Freso commentedWorks now with both long and short aliases! Yay! And I see no more nits to pick at (well, perhaps
truncate_utf8could be referenced with a pair of parentheses... but I'm somewhat indifferent on that). :pComment #20
Freso commentedIt breaks the tests though, but this is likely because the tests themselves need to be updated for this new logic.
Comment #21
Freso commentedActually, without this follow-up patch, it'll break two tests, but with it, it'll only break one. So it's an improvement. The test still breaking is "[testPathAuto]: Node accessible through alias at [[...]/sites/all/modules/pathauto/tests/pathauto.test line 84]", which tries to fetch the node using the alias.
Comment #22
Freso commentedAnd even reverting the originally committed patch from this issue doesn't take the fail away.
Comment #23
gregglesAnd fixed - http://drupal.org/cvs?commit=131753
Thanks for the reviews/testing.
Comment #24
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #25
loze commentedI know this is a year old, but did this ever make it into the official release?
I cant seem to get this functionality to work. my url titles are being cut off in mid word.
Is there an option to enable this that im missing?
thanks.
Comment #26
theshanergy commentedThere is a similar issue at the beginning of an url - if you have a page who's title starts with a short word (ie. 'to') it will remove it, but leave the separator. Creating a node titled 'To Something' creates an url of '/-something', instead of just '/something'.
Comment #27
greggles@msiama - is that problem still present in Pathauto or did this patch fix it (this patch is in the tip of 6.x-2.x dev and in 6.x-1.2
Comment #28
interestingaftermath commentedI hate to be a pain but I am experiencing this issue with the 6.x-1.4 release.
This: Broker Commissions Will Get Squeezed by Health Reform, but a New 'Navigator' Role Is Seen Growing
translates to this: ...enews/archive/2010/07/07/Broker-Commissions-Will-Get-Squeezed-Health-Reform-New-Navigator-Role-Seen-
I didn't think I should have to mess with the patch since it's from like 2 years ago. What am I doing wrong?
Comment #29
dave reid@interestingaftermath: Can you please file a new issue detailing exactly what's going wrong for you instead of opening tickets that have been closed for several months or years?
Comment #30
interestingaftermath commentedDave, this is the second post you've made that comment on but I really don't understand your reasoning... The issue is DIRECTLY related to this one (as was the other issue). I will open a new issue as requested but it really seems pointless and unorganized. People can read timestamps, that's what they're for.