0
votes

In Typo3 I have a content element with a plain text field (no RTE / CKEditor field). In case a user enters an e-mail address, it should be automatically converted into an e-mail link. How can I achieve this with Typoscript or even directly in Fluid-Script?

This is my approach: per <f:cObject ... /> pass the text to a typoscript, which searches for an @-character, selects the whole word and then adds the corresponding A-tags:

<f:cObject typoscriptObjectPath="lib.emaillink" data={adrtxt: tx_mask_cnt_consultation_adr_item_txt} />
lib.emaillink = COA
lib.emaillink {
    
    5 = LOAD_REGISTER
    5 {
       dAdrTxt.data = field:adrtxt
    }
    
    10 = TEXT
    10 {
         data = register:dAdrTxt
         # Search for '@', select whole word, add A-tags ... ?
    }
    
}

Thank you in advance for any help!

1
With TypoScript, replacement with regular expression should solve this. - Julian Hofmann

1 Answers

0
votes

That was a feature of TYPO3, but it changed in details from version to version.
Sometimes you need a prefix mailto: sometimes you must avoid that prefix.

Especially if you want to hide the emailaddress from email-harvesters, an email was encrypted linked with javascript and the visible (original) email address was modified to fool regexp searching.

have a look at the manual

config {
    spamProtectEmailAddresses = -5
    spamProtectEmailAddresses_atSubst = <span class="at">(at)</span>
}

(with the option to replace all span-tags with class at by a simple @ on runtime, so the email looks normal to a visitor.

As I always use this encryption, I can't say whether it only works with this feature active. Give it a try.