XF 2.2 Use preg_replace on variable in template

Arno Nühm

Active member
I would like to strip all special characters from $__globals.thread.title variable.

$__globals.thread.title|replace("/[^0-9a-zA-Z \-\_]/", "")
doesn't work.

How can I do this?
 
This is a bit meh but it works.

HTML:
<xf:set var="$specialChars" value="{{ ['ç', 'ş', 'ö'] }}" />

<xf:foreach loop="$specialChars" value="$char">
    <xf:set var="$thread.title" value="{{ $thread.title|replace($char, '') }}" />
</xf:foreach>

Obviously you need to define the array of special chars so it's not ideal.
 
Top Bottom