Results 1 to 5 of 5

Thread: RSS displaybox: make the links in the text clickable

  1. #1
    Join Date
    Oct 2010
    Location
    Italy
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default RSS displaybox: make the links in the text clickable

    1) Script Title:
    RSS Displaybox

    2) Script URL (on DD):
    http://www.dynamicdrive.com/dynamici...ybox/index.htm

    3) Describe problem:
    Hi,
    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

    P.S
    Hironically, vbulletin has already highlighted it and made it clickable.
    Last edited by flapane; 10-19-2010 at 10:33 PM.

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    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:

    Code:
    <?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.
    DD Admin

  3. #3
    Join Date
    Oct 2010
    Location
    Italy
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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.

    ty

  4. #4
    Join Date
    Oct 2010
    Location
    Italy
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I've made it!
    If anybody needs it (or if you want to include it in the original Script), here's the code:

    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);
    Code:
    <?php echo $item_link; ?>
    Last edited by flapane; 10-24-2010 at 11:31 AM.

  5. #5
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Glad to hear, and thanks for sharing the solution!
    DD Admin

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •