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 😉
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?
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.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.