1. 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

Discussion in 'Styling and Customization Questions' started by BamaStangGuy, Sep 29, 2016.

  1. BamaStangGuy

    BamaStangGuy 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)?
  2. Mike

    Mike XenForo Developer Staff Member

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

Share This Page