[TYPO3] Replacing a character during content rendering

Xavier Perseguers typo3 at perseguers.ch
Sat Mar 1 23:27:13 CET 2008


> I would like to replace all straight apostrophes (') with the ’ 
> character in all my text and text w/image blocks. The reason is that the 
> straight apostrophe is not good in a typesetting context.

I found a better way but it still isn't as fine as I wished.

As I use TemplaVoila, I edited the DS to read:

-- cut ---------------------
10= RECORDS
10.stdWrap.postUserFunc = user_parseFunc->replaceApostrophes
-- cut ---------------------

and I created a file class.user_parseFunc.inc:

-- cut ---------------------
<?php
class user_parseFunc {
         function replaceApostrophes($content, $conf) {
                 return str_replace("'", '’', $content);
         }
}
?>
-- cut ---------------------

The problem is that this method is called for the whole page content, 
not for every content element. That is, I cannot bypass the str_replace 
function for content block whose type is not "text" or "text w/ images". 
As such, I get my apostrophes being replaces everywhere, that's a bit 
too much.

There seems to be a possible hook in 
typo3/sysext/cms/tslib/class.tslib_content.php, function stdWrap, 
configuratoin "postUserFunc". But 1) I don't know if it is the place to 
hook and 2) I cannot find a way to hook there actually.

Any help?

Xavier Perseguers


More information about the TYPO3-english mailing list