We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6531
    • 154 Posts
    I am putting a twitter feed on my site. I would like the links in the feed to be clickable. Currently getfeed gets the URL but it is not a link.
    Is there some way to add the "<a href" etc ?
    Maybe with an output filter? (":replace=") Does that take standard regex?

    Thanks
      • 20364
      • 89 Posts
      Here you go:
        function convertURLsToLinks ( $toConvert )
        {
          
          $toConvert = preg_replace("{([^\'\"\>]){1}(http://|www\.)+([\w\.\/]*)}is", " <a href=\"http://$3\" target=\"_blank\">http://$3</a>", $toConvert);
          $toConvert = preg_replace("{([\'\"\>]){1}(http://|www\.)+([\w\.]*)([\'\"\<]){1}}is", " $1http://$3/$4", $toConvert);
          $toConvert = preg_replace("{([^\'\"\>]){1}([\w\.]+)(@)([\w\.]+)}is", " <a href=\"mailto:$2$3$4\" target=\"_blank\">$2$3$4</a>", $toConvert);
          $toConvert = preg_replace("(@([a-zA-Z0-9]+))", "<a href=\"http://www.twitter.com/\\1\" target=\"_blank\">\\0</a>", $toConvert);
          return $toConvert;
          
        }
        • 36607 ☆ A M B ☆
        • 44 Posts
        I’m not a developer and don’t know php. Does this code go in the getfeed snippet?