1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.5 String replace in XenForo template

Discussion in 'XenForo Questions and Support' started by LPH, Mar 27, 2016.

  1. LPH

    LPH Well-Known Member

    Is it possible to use a string replace in a XenForo template?

    Consider the following postbit template change:
    <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.

    str_replace(' ''-'$authorUsername );
    Is there a better way to replace the space with a hyphen in a template?
  2. wang

    wang Well-Known Member

    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.

Share This Page