Attention
TYPO3 v12 has reached end-of-life as of April 30th 2026 and is no longer being maintained. Use the version switcher on the top left of this page to select documentation for a supported version of TYPO3.
Need more time before upgrading? You can purchase Extended Long Term Support (ELTS) for TYPO3 v12 here: TYPO3 ELTS.
Replace ViewHelper <f:replace>
The ReplaceViewHelper replaces one or multiple strings with other
strings. This ViewHelper mimicks PHP's
str_ function.
However, it's also possible to provide replace pairs as associative array
via the "replace" argument.
Examples
Replace a single string
<f:replace value="Hello World" search="World" replace="Fluid" />
Hello Fluid
Replace multiple strings
<f:replace value="Hello World" search="{0: 'World', 1: 'Hello'}" replace="{0: 'Fluid', 1: 'Hi'}" />
Hi Fluid
Replace multiple strings using associative array
<f:replace value="Hello World" replace="{'World': 'Fluid', 'Hello': 'Hi'}" />
Hi Fluid
Go to the source code of this ViewHelper: ReplaceViewHelper.php (GitHub).
Arguments
The following arguments are available for the replace ViewHelper:
replace
-
- Type
- mixed
- Required
- 1
search
-
- Type
- mixed
value
-
- Type
- string