[TYPO3-english] convert <link> to html <a> tag

Sergey Alexandrov serg at alexandrov.us
Fri Mar 29 16:04:58 CET 2013


if you need to replace only links try something like this.

$pattern = "/(<link ([^>]*)>)(.*?)(<\/link>)/si";
preg_match_all($pattern,$message,$regs);
for ($i = 0; $i < count($regs[0]); $i++)
{
     if (is_numeric($regs[2][$i]))
     {
         // Internal link
         $message = str_replace($regs[1][$i],'<a 
href="http://your_host_name/index.php?id='.$regs[2][$i].'">',$message);
     }
     else if (ereg('@',$regs[2][$i]))
     {
         // Email address
         $message = str_replace($regs[1][$i],'<a 
href="mailto:'.$regs[2][$i].'">',$message);
     }
     else
     {
         // External links
         $message = str_replace($regs[1][$i],'<a 
href="'.$regs[2][$i].'">',$message);
     }
}

On 3/29/2013 6:09 AM, Dawid Pacholczyk wrote:
> Hello,
>   TYPO3 keeps hyperlinks as <link http://target.loc - some more
> data>Label</link>
>
> I'm writing exporter of my content to the external system that isn't based
> on TYPO3 so I need to convert this link to normal <a
> href="target.loc">Label</a>
>
> How can I do this while exporting thata from BE module to xml or text file ?
>
> Best regards,
> Dawid Pacholczyk
>



More information about the TYPO3-english mailing list