Theme editor

Browser Detection

Browser Detection

Browser Detection 2.4.0

XF 2.3 Addons · by Staraddons
0 Downloads 26 Views 0 Version
A light-weight shim around Mobile_detect for XenForo 2
Price
Free
There are no downloadable versions available for this resource yet.

Overview Version (0) Discussion (2) License

  • 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
    There are no downloadable versions available for this resource yet.
  • 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)

  • License Terms

    By purchasing this resource, you are granted a license to use it on one (1) site, for as long as your license remains valid. You are not purchasing ownership of the underlying code.

    How your license works
    • Your license is checked automatically in the background. This never affects your site's visitors.
    • As long as your license is valid, this resource keeps working normally — even if our license server is briefly unreachable, a temporary network issue will never disable it.
    • Your license is bound to your site's domain the first time it's used.

    Moving to a new domain?
    Contact us and we'll move your license for you.

    What's included
    Updates and support for the period stated on this resource's page (see the Version tab for the current release).

    What's not allowed
    • Sharing your license with others, or using it on more than one site at a time
    • Removing or bypassing the license check in the code
Resource information
Category XF 2.3 Addons
Author Staraddons
Date Dec 7, 2025
Latest version 2.4.0
Statistics
Views 26
Downloads 0
Version 0
Developer
Staraddons
Resource author
More resources
Back
Top