We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Long links (url's) in forum messages break layout

Development and Programming

Garrulus's avatar
Garrulus
10 posts
17 years ago
Garrulus's avatar Garrulus

I’m running a forum for people who love to go hiking. I’m really pleased with the forum module.

My members very often post links to Google Maps (and the like) which are usually extremely large. e.g. http://maps.google.com/maps/ms?ie=UTF8&hl=en&msa=0&ll=45.932289,6.872978&spn=0.130137,0.214233&t=p&z=12&om=1&msid=117060382265508849582.000443713748a0f014275

Can I somehow shorten long links, like http://maps.google.com/maps?f=q&hl=e… so that they do not break the layout of my site (as it does with this forum)? For EE weblogs:entries there are several plugins available that shorten strings of text, but as of yet, I haven’t found one for the forum.

I know that you can use the [url] tags, but try and explain that to them 😉

       
lumis's avatar
lumis
119 posts
17 years ago
lumis's avatar lumis

the quickest method would be to wrap each post in a div tag and set the width and also set overflow hidden



						
       
Garrulus's avatar
Garrulus
10 posts
17 years ago
Garrulus's avatar Garrulus

I know this technique.

Too bad the rest of the text will also be hidden, as it wraps along with the long url… So, it is not an option.

       
dombi's avatar
dombi
130 posts
17 years ago
dombi's avatar dombi

I use tinyurl, which shortens the links: http://tinyurl.com/

       
Garrulus's avatar
Garrulus
10 posts
17 years ago
Garrulus's avatar Garrulus

Thanks dombi… I know about TinyURL. But I think my users will probably grasp the usage of pmCode like [url=] more easily than that web service. In other words: good for the nerds, bad for normal people ;-)

I know that other forum boards have this url-shortening feature (phpBB comes to mind). If it is not possible with EE Forum 2.0, than maybe it’s something development could add in the 3.0 version?

Should I post a feature request about this?

       
Robert Wallis's avatar
Robert Wallis
36 posts
17 years ago
Robert Wallis's avatar Robert Wallis

Well, it’s totally unsupportable, and it will break when new versions come out but… 😊 you could hack the module code.

I don’t have the forum module, but in the Typography class there’s a function called auto_linker that takes plain text and turns it into pMcode. So this is the place that you want to mess up in the forum module code. However if the forum module is using Typography, then you want to mess up core/core.typography.php

In the auto_linker there is a line that uses preg_replace_callback and auto_linker_callback in an array. But the big clue is that the regex says something about http in it. So just after that line you want to put in something like this:

$str = preg_replace("#(\[url=http://maps.google.com/[^\]]+\])(http://maps.google.com/[^\[]+)\[/url\]#im", '\\1http://maps.google.com/...[/url]', $str);

Seriously, this is a bad idea because when you upgrade EE it will change this and it’s an obvious hack that might introduce crazy bugs and may void your warranty. :red: So don’t do it even though it does exactly what you want it to do and I gave you all the steps. Just kidding it works fine, but seriously you shouldn’t do it.

Oh yeah, and back up the code and all that good stuff before doing anything.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.