XF 1.5 String replace in XenForo template

LPH

Well-known member
Is it possible to use a string replace in a XenForo template?

Consider the following postbit template change:
Code:
<a href="https://www.domain.com/wp/author/{$user.username}/">WordPress Author</a>

The link is going to a WordPress installation. Usernames with spaces are not allowed in WordPress authors, creating a 404 unless the space is replaced with a hyphen.

PHP:
str_replace(' ', '-', $authorUsername );

Is there a better way to replace the space with a hyphen in a template?
 
I do not think you can do that directly on a template in xenforo. What you can do, is to use str_replace on a template hook. That should work.
 
Top Bottom