XF 2.1 strpos in templates

grantus

Active member
I've been searching but I don't see anything about strpos. What would be the equivalent in a template?

Basically, I want to do this:
Code:
<xf:if is="strpos({$xf.uri}, 'forums') !== false">
    forums
<xf:else />
    {$xf.uri}
</xf:if>

because I just need to see if the URL contains certain words so I can do an if/else.
 
You can use the contains function (contains($xf.uri, 'forums')), though note it is case-insensitive.
 
I don't think it's used anywhere in the core. You can view a full list of template functions and filters in src/XF/Template/Templater.php.
 
Top Bottom