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

XF 1.4 Can you use LIKE conditionals?

Discussion in 'XenForo Questions and Support' started by Phases, Dec 2, 2014.

  1. Phases

    Phases Active Member

    I'm trying to do something like this:
    <xen:if is="{$forum.title} LIKE 'root'">

    <xen:if is="{$forum.title} == '%root%'">
    or something similar I've tried a few things. Is there a way to do this? Looking for basically any forum name with the word root in it to be returned true. Appreciate any help!

    Edit: Answer posted below:

    Last edited: Dec 3, 2014
  2. Brogan

    Brogan XenForo Moderator Staff Member

    I have never actually tested that but I don't believe it's possible to do a partial match on a variable in that manner.
  3. Phases

    Phases Active Member

    In the words of my wise 'ol man, Dag-gummit.

    Hopefully we'll be surprised with someone swooping in to save the day.

  4. Mike

    Mike XenForo Developer Staff Member

    <xen:if is="strpos({$forum.title}, 'root') !== false">
    Should work.
    Brogan, Phases and Jeremy like this.
  5. Phases

    Phases Active Member

    Didn't work at first, then realized case sensitive. I needed "Root", my bad.

    You're the man Mike, thanks.
  6. dknife

    dknife Active Member

    stripos is the case insensitive version just FYI
    Phases likes this.

Share This Page