break up long url text using wordwrap()
udijw - March 12, 2007 - 18:57
| Project: | Go - url redirects |
| Version: | HEAD |
| Component: | Code |
| Category: | feature request |
| Priority: | minor |
| Assigned: | spiderman |
| Status: | won't fix |
Description
currently the target URL is displayed in one line. sometimes this target URL is long and it "disturbs" the format of the page.
can the target URLs span multiple lines?
thanks

#1
As the 4.7.x branch has been dropped, I am moving this to 5.x as the issue is still valid.
#2
definitely a valid point- i've seen this one in my own testing, and it's a pain. i think a decent approach to this would be to wrap the link text in a call to wordwrap().
we could then give the admin control over the configurable parameters "width", "break" to define a maximum length of the text and what character to break it with (a space might be sufficient, in some cases). the "cut" flag might also be useful, to select mid-word character break.
if people agree with this approach, i definitely volunteer to roll a patch for this one :)
#3
attached is a patch against the latest gotwo.module (1.5.2.3) which adds three admin settings for enabling word wrapping, setting wrap width, and selecting the character to wrap with (space or newline). the implementation in __gotwo_filter is then a few simple lines to call wordwrap() before writing out the final tag.
feedback on the general approach as well as the specifics of the patch are greatly appreciated :)
#4
Why are we not using CSS here? Maybe we make the URL hidden and a mouse over will show the complete URL as tool tip.
#5
IMHO, wordwrap() introduces extra code for little gain. I think the tool tip idea is brilliant. Very simple and gets the job done. +1
#6
We could also reuse this core function...
<?php/**
* It is possible to adjust the width of columns generated by the
* statistics module.
*/
function _statistics_link($path, $width = 35) {
$title = drupal_get_path_alias($path);
$title = truncate_utf8($title, $width, FALSE, TRUE);
return l($title, $path);
}
?>
what ends in "http://www.example.com/verylongurl...".
#7
hass, that's a brilliant find. I feel stupid for not finding this sooner! Let's keep it consistent with core so +1 from me!
#8
2 possible ways... make gotwo depend on statistics module and reuse the same function, or duplicate code... I think duplicating here gives us something more... not sure if everyone using gotwo like to activate statistics. :-)
#9
I am using statistics module. While its safe to assume whoever is interested in gotwo.module will also be interested in stats in general, due to the strain statistics.module places on the database, I don't think it's wise to make this module depend on it.
As a result, I think it's easier and more flexible to just duplicate the code. However, I still like the idea of showing the full URL as a tooltip in addition to using _statistics_link()
#10
#11
ok i like the idea of using truncate_utf8() to allow for just shortening long urls, but i think the point of the original request was not to cut off the text, but just make it possible to wrap.
i've re-rolled this patch so the admin settings provide an option: either use wordwrap() to split long text up, or use truncate_utf8() to provide shortening of urls to a specified length. attached is the new patch for review. thoughts on this approach?
#12
Feel free to post a patch with a user friendly version, without any extra settings, for e.g. like #6, otherwise close at latest in 3 months.
#13