TYPO free

home

fighting for TYPO free code

Replace Content extension relased

22 Mar 2013

The Replace Content extension searches for patterns in the generated TYPO3 page using one or more regular expressions and then replaces those instances with a replacement.

The search and replace takes place after the complete page has been generated by TYPO3.

It uses the tslib_fe hook for post-processing of page content cached/non-cached: 'contentPostProc-all'.

The extension can be configured using TypoScript. You define an array of search regexes and a matching array of replaces. Each pattern will be replaced by the replacement counterpart. If there are fewer elements in the replacement array than in the pattern array, any extra patterns will be replaced by an empty string.

The preg_replace rules apply: https://www.php.net/preg_replace

Here is an example that prefixes all links to files in typo3temp, fileadmin and uploads with https://your.domain.tld/. This configuration can be used to set up a cookie free domain.

You may have other uses. You are totally free to do anything regular expressions allow you to do.

Constants:

config.tx_replacecontent {

host = your.domain.tld

schema = https://

} 

 

Setup:

config.tx_replacecontent {

search {

1 = #(src|href)=("|')(/?)([^/]*/)?(typo3temp|fileadmin|uploads)/#

}

replace {

1 = $1=$2{$config.tx_replacecontent.schema}{$config.tx_replacecontent.host}/$4$5/

}

}

 

 

add comment
Commenting is closed for this item