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

XF 1.5 Template Conditional Syntax

Brent W

Well-known member
So I have a basic add-on that sets the Country Code based on Cloudflares GeoIP header.

The Listener is:

class BamaStangGuy_CFGeoIP_Listener
    public static function template_create(&$templateName, array &$params, XenForo_Template_Abstract $template)
         $params['countryCode'] = $_SERVER["HTTP_CF_IPCOUNTRY"];

I am using this template conditional:

<xen:if is="{$countryCode} == 'IN' OR {$countryCode} == 'RU' OR {$countryCode} == 'CN'">
Is there a better conditional I can use (shorter using an array)?


XenForo developer
Staff member
You should be able to use in_array. Something like:
<xen:if is="in_array({$countryCode}, array('IN', 'RU', 'CN'))">