• 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
#1
So I have a basic add-on that sets the Country Code based on Cloudflares GeoIP header.

The Listener is:

Code:
<?php
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:

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

Mike

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