[Typo3] Another solution to the direct mail link problem (HTML entities in urls)

Armin Günther armin.guenther at augusta.de
Wed Sep 21 10:16:30 CEST 2005


Hi list,

there are several postings about html entities in the urls/links of 
direct mail mailings. Mostly the '&' is replaced by the html entity 
'&', either directly or in the recoded jumpurls.

Suggested solutions recommend changes in the source code,
* either changing fe_adminLib.inc by remove calls to htmlspecialchars() 
where urls are affected
* or removing the html entities in tslib/class.tslib_fe.php after 
decoding the jumpurl by adding something like this:
$this->jumpurl = str_replace('&','&',$this->jumpurl);

Ad hoc changes of source code are problematic however (changes are not 
preserved with upgrades for example), so I would recommend another 
solution:

HTML-encoding of links happens, when pagecontent is rendered (so the 
problem is not "Direct Mail" specific: if you use external links with 
query parameters the same problems may arise!). So why not configure the 
HTMLparser so as to render urls the way you need them? Using

'HTMLparser.tags.a.fixAttrib.href.userFunc'

you are able to call a user function that may change the href attribute 
as you like it. The user function might be very simple:

    function url_recode($content,$conf)	{
       return  str_replace ( '&', '&', $content);
    }

I put this function in a litte extension and use it (for example) in the 
following way (of course this is dependent on your specific 
configuration/TS templates!):

lib.parseFunc_RTE.HTMLparser.tags.a.fixAttrib.href.userFunc = 
tx_userfunctions_pi1->url_recode
tt_content.text.20.parseFunc=<lib.parseFunc_RTE

Now at least the urls in content elements tt_content.text.20 (bodytext) 
is rendered as I need them and links in direct mails (directly or via 
jumpurl) including these content elements are correct.

Armin



More information about the TYPO3-english mailing list