Theme editor

Browser Detection

Browser Detection

Browser Detection 2.4.0

XF 2.3 Addons · by Staraddons · StarAddons Verified Vendor
0 Downloads 25 Views 2 Version
A light-weight shim around Mobile_detect for XenForo 2
Price
Free
Available
Download

Overview Version (2) Discussion (2)

  • Browser Detection
    Browser Detection
    A light-weight shim around Mobile_detect for XenForo 2
    browser
    browser detection
    mobile
    About this resource
    A light-weight shim around Mobile_detect for XenForo 2

    Usage (in templates)

    The add-on injects the global variable $xf.mobileDetect, check that the variable is set before calling any methods to prevent errors during upgrades or if the add-on is disabled.

    HTML:
    Expand Collapse Copy
    <xf:if is="$xf.mobileDetect && $xf.mobileDetect.isMobile()">
        Is Mobile
    <xf:else />
        Not Mobile
    </xf:if>

    HTML:
    Expand Collapse Copy
    <xf:if is="$xf.mobileDetect && $xf.mobileDetect.is('Firefox')">
        Is Firefox
    <xf:else />
        Not Firefox
    </xf:if>

    HTML:
    Expand Collapse Copy
    <xf:if is="$xf.mobileDetect && $xf.mobileDetect.is('Chrome')">
        Is Chrome
    <xf:else />
        Not Chrome
    </xf:if>

    Usage (in php)

    PHP:
    Expand Collapse Copy
    $mobileDetect = \SV\BrowserDetection\Listener::getMobileDetection();
    $isMobile = $mobileDetect && $mobileDetect->isMobile() ? "_m1" : "_m0";

    XF2.1 Page caching

    The integration mobile detection with XF2.1+ full-page caching, add to the config.php this;
    PHP:
    Expand Collapse Copy
    $config['pageCache']['onSetup'] = function (\XF\PageCache $pageCache) {
        $pageCache->setCacheIdGenerator(function(\XF\Http\Request $request) {
            return \SV\BrowserDetection\CacheHelper::getPageCacheId($request);
        });
    };

    Contributing features or bug fixes
    Please create a Github Pull request via the "More information." link.
  • Version
    2.4.0 Stable Available Feb 8, 2026 · 0
    File size: 44.3 KB
    SHA-256: 243feebefd9610247cb6aaf12ab0de42916a7f0da5f6252784d4d67b7041b8b6
    SHA-256 verified Package valid Compatibility checked Last verified:
    • Restore XF2.1 support
    • Update Mobile Detect from v3.74.3 => v4.8.06.
      Note; this is a fork which retains php 7.2 compatibility
    2.3.1 Stable Available Dec 7, 2025 · 0
    File size: 41.5 KB
    SHA-256: 0ef9ff933dfbee234c6b92496e09666047065f0c30606efa92461fb1d66fb836
    SHA-256 verified Package valid Compatibility checked Last verified:
    A light-weight shim around Mobile_detect for XenForo 2

    Usage (in templates)

    The add-on injects the global variable $xf.mobileDetect, check that the variable is set before calling any methods to prevent errors during upgrades or if the add-on is disabled.

    HTML:
    Expand Collapse Copy
    <xf:if is="$xf.mobileDetect && $xf.mobileDetect.isMobile()">
        Is Mobile
    <xf:else />
        Not Mobile
    </xf:if>

    HTML:
    Expand Collapse Copy
    <xf:if is="$xf.mobileDetect && $xf.mobileDetect.is('Firefox')">
        Is Firefox
    <xf:else />
        Not Firefox
    </xf:if>

    HTML:
    Expand Collapse Copy
    <xf:if is="$xf.mobileDetect && $xf.mobileDetect.is('Chrome')">
        Is Chrome
    <xf:else />
        Not Chrome
    </xf:if>

    Usage (in php)

    PHP:
    Expand Collapse Copy
    $mobileDetect = \SV\BrowserDetection\Listener::getMobileDetection();
    $isMobile = $mobileDetect && $mobileDetect->isMobile() ? "_m1" : "_m0";

    XF2.1 Page caching

    The integration mobile detection with XF2.1+ full-page caching, add to the config.php this;
    PHP:
    Expand Collapse Copy
    $config['pageCache']['onSetup'] = function (\XF\PageCache $pageCache) {
        $pageCache->setCacheIdGenerator(function(\XF\Http\Request $request) {
            return \SV\BrowserDetection\CacheHelper::getPageCacheId($request);
        });
    };

    Contributing features or bug fixes
    Please create a Github Pull request via the "More information." link.
  • Discussion

    This resource has a discussion thread on the forum where you can ask questions, report issues, and talk with the author and other users.

    Join the discussion (2)

Resource information
Category XF 2.3 Addons
Author Staraddons
Date Dec 7, 2025
Latest version 2.4.0
SHA-256 243feebefd9610247cb6aaf12ab0de42916a7f0da5f6252784d4d67b7041b8b6
Security
File integrity SHA-256 verified
SHA-256
243feebefd9610247cb6aaf12ab0de42916a7f0da5f6252784d4d67b7041b8b6
How to verify this file
Statistics
Views 25
Downloads 0
Version 2
Developer
Staraddons
Resource author
More resources
Back
Top