very long url does not wrap and runs off page. makes everything too wide

mwu - August 30, 2006 - 19:00

I have very long url's that run off the page. They are making the entire body too wide so that everything scrolls off the screen.

I am using bluemarine and cck. But this is a problem in story.module as well.

I tried to read about this. There seem to be many complicated solutions involving writing custom php text wrap solutions.

But I think there must be a simple solution.

Please tell me about all the options, simple to complex! thank you.

htmlwrap module

xjm - August 30, 2006 - 20:12

Take a look at the htmlwrap module maybe?
http://drupal.org/node/24027

I haven't tested this module myself and don't know if it will correctly handle the visible URLs for you, but from the description it sounds like it should.

I know that the drupal site adds an ellipsis to the url text by default if it's too long:
http://not-a-real-url.com/a/lotsoftextinastring/123565456423424/2654645/...

=======================
Just another newbie.
XHTML Strict: it's the way to be.
=======================

html wrap

mwu - August 30, 2006 - 20:35

good idea. you have a good handle on modules. how did you know about this?

the description in admin says this:
Automatically breaks up long words to prevent word wrapping format problems. Will not break html formatting or URLs.

but the description on the project says this
This is a common problem on site with newbie or troll commenters who post ong urls, or nonsense words to destroy the site layout

the 2 seem to contradict. i'll try it and report back.

anyone else with ideas please post!

I was confused by that too

xjm - August 30, 2006 - 20:50

I was confused by that too at first. I think it means it won't break the url inside the tag, but it will change the url that's displayed. E.g.:

<a href="http://this-wont-be-changed.com/">http://this-might....</a>

Guessing though. :)

=======================
Just another newbie.
XHTML Strict: it's the way to be.
=======================

URL Shortener

gabrys - March 18, 2008 - 21:43

look at this :
http://smarturl.eu

works!

mwu - August 30, 2006 - 20:47

works for story and cck!

the good news is that it broke up a very long url for story.module

the poster would have to manually choose that format

for cck, for that field, you will have to choose "filtered text" instead of "plain text" to get the input formats option. (thanks to a thread by ramdak)

(I couldn't do multiple select on input formats. I thought it was possbile, but I don't need it at the moment.)

I'm using urlfilter module

drupal librarian - August 30, 2006 - 20:43

I'm using urlfilter module and satisfied with it so far. It does two things:
1) Makes URLs clickable links
2) Trunkates URLs longer than a certain number of symbols that you can define yourself in the settings.
http://drupal.org/project/urlfilter

thank you

mwu - August 30, 2006 - 21:07

thank you Natalie. I've used urlfilter before but never knew about the setting. you dug that up pretty well, because it's not in the documentation anywhere.

Yes, it's a recent addon and

drupal librarian - August 30, 2006 - 21:59

Yes, it's a recent addon and hasn't been documented yet. I suppose we should remind the author or just add a comment in the documentation section.

htmlwrap vs urlfilter

mwu - August 30, 2006 - 21:01

ok urlfilter also works.

urlfilter is by steven wittens (just about the second most experienced developer after dries)
htmlwrap is by aaron welch, who does the airamerica radio site. so both are top drupal developers and both modules should be pretty bug-free.

they are different.
1) urlfilter let's you truncate after a default value. (I typed in a value, not sure if it was saved, because the default value continues to show in the box. Have not looked in phpmyadmin.)

the link is now the first half of the url. if a user does ignorantly clicks on the broken half link, the user will be lead to the wrong place.

however, the poster does not need to do anything special.

I didn't want clickable url's for security reasons. I want the user to think a little before they just click a link that could lead to a malicious site.

2) htmlwrap. the url is not clickable. user might realize they need to copy and paste the entire thing.

drawback is poster has to manually choose the format.

anyone up for patch htmlwrap so that admin can set it as on for a long "url field" in cck?

if anyone else knows about other modules, please post!

ways of handling the problem

xjm - August 30, 2006 - 22:16

Well, if you want the long urls to be shortened or wrapped, but do not want them to be clickable, that requires a somewhat more specialized solution. Here's a few ways I could think of for handling the problem:

  1. Use a filter like those suggested, with a clickable url, to get:
    <a href="http://really-long-stuff../index.html">http://shortened...</a>
    And:
    • have the full url as the title so users can see the whole thing when they hover the mouse over it, and/or
    • have an advisory to your users recommending they use discretion, or
    • have an intermediate "landing page" (or popup window I suppose--yuck). The IRS uses this method. It'd say something like:

      You are now leaving http://mysite.com. We cannot verify the security or authenticity of (website x)
      The full URL you have requested is:
      http://really-long-stuff..../index.html
      I understand the potential risks; Visit this link

  2. have a non-clickable URL that wraps, with:
    • instrutions to copy both parts of the URL, possibly supplemented with
    • a javascript to help the user copy the full URL to the clipboard (potential accessibility issues)
  3. Instead of a link or plain text, a form text box containing the full URL, so that users can highlight the whole thing easily to copy it

My personal advice is that clickable URLs are much better for usability, but the text box idea seems like a good second choice if you really don't want URLs clickable. Of course this would probably also require some custom development (like a new filter).

I guess the next question is, which of these options for the user interface would work best for you?

=======================
Just another newbie.
XHTML Strict: it's the way to be.
=======================
Feature request: HTML Source Formatting in TinyMCE

What about using CSS

Paul Adler - February 20, 2007 - 07:01

You could add a overflow: hidden style in your style sheet to the elements that contain the text you want to wrap. I have done this with my sidebar and content classes. This article is also useful - http://www.positioniseverything.net/explorer/expandingboxbug.html The urls are not clickable, but for blocks that show recent comments, it doesn't really matter. This method would have a very minimal performance impact.

Why not use url-shrinker

webpro15yrs - May 1, 2007 - 01:52

Download desktop software from http://www.url-shrinker.com and shorten any url anytime. They last forever.

A quick and easy solution

Yebot - August 8, 2007 - 14:51

A quick and easy solution for you might be use a web-based url shortener like:

http://littlurl.com

 
 

Drupal is a registered trademark of Dries Buytaert.