View Full Version : RSS displaybox: make the links in the text clickable

10-19-2010, 05:13 PM
1) Script Title:
RSS Displaybox

2) Script URL (on DD):

3) Describe problem:
I'd like to automatically recognize (and higlight) the urls in the text and not just in the title.

An example I wrote by modifying the demo:
jQuery Mobile (alpha) released
19 Oct 2010 5:23 am
The long awaited jQuery Mobile alpha has been released, intended to bring jQuery's functionality to mobile devices. See it here http://foo.bar.com
In a related note, jQuery 1.4.3 was also just released, and with it a handful of concrete improvements.


Any way to make that http://foo.bar.com clickable?

Thanks in advance

Hironically, vbulletin has already highlighted it and made it clickable. :)

10-20-2010, 04:45 AM
This is probably something best done using PHP, by parsing the body of each RSS entry looking for links and adding a HREF tag around it. For example, inside outputbody.php, the following line is what outputs the BODY of each RSS entry:

<?php echo $item->get_description(); ?>

My PHP is a little rusty, but basically you'd go through this content and make the necessary changes before actually outputting it.

10-20-2010, 10:04 AM
That makes sense, thanks.
I'm not THAT much into php too, so if anybody has an idea and would want to write a couple of lines, it would be really appreciated.


10-24-2010, 11:26 AM
I've made it!
If anybody needs it (or if you want to include it in the original Script), here's the code:

//recognize urls in the text by flapane.com
$item_link = $item->get_description();
$item_link = preg_replace("/(?!(?:[^<]+>|[^>]+<\/a>))\b((http:\/\/)(.*?)\/([\w\.\/\&\=\?\-\,\:\;\#\_\~\%\+]*))\b/is", "<a href=\"\\1\" target=\"\\_blank\">\\1</a>",$item_link);

<?php echo $item_link; ?>

10-25-2010, 07:30 AM
Glad to hear, and thanks for sharing the solution!