Resource icon

Browser Detection 2.4.0

No permission to download
Compatible XF 2.x versions
  1. 2.1
  2. 2.2
  3. 2.3
Additional requirements
php 7.2+
License
MIT Licence
Visible branding
No
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:
<xf:if is="$xf.mobileDetect && $xf.mobileDetect.isMobile()">
    Is Mobile
<xf:else />
    Not Mobile
</xf:if>

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

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

Usage (in php)

PHP:
$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:
$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.

Contributions

If you appreciate this add-on, please consider a contribution via PayPal. Details will be provide via private conversation.

Please contact me if you wish for different licencing arrangements.

Licence

See MobileDetectLicense.md for Mobile-Detect's licence (MIT licensed)
Author
Xon
Downloads
497
Views
10,299
First release
Last update

Ratings

4.00 star(s) 4 ratings

More resources from Xon

Latest updates

  1. 2.4.0 - Feature update

    Restore XF2.1 support Update Mobile Detect from v3.74.3 => v4.8.06. Note; this is a fork which...
  2. 2.3.1 - Maintenance update & XF2.3 support

    XF2.3 support php 8.4 compatibility Update MobileDetect library to 3.74.3
  3. 2.3.0 - Feature update

    This add-on is now available on atelieraphelion.com Require XenForo 2.2+ Require php 7.2+...

Latest reviews

it does a terrible job. as an alternative, another newly released extension performs better and misses almost no browsers or operating systems.
Hi, Xon, and thank you for this add-on!

Would be nice to have a Mobile-Detect to be updated to latest in this add-on.
Hi, I had a problem with the guest cache, and now with this addon I have solved it.
Thank you very much!
Good addon i like :) But i have a question? Can i change theme for mobile. If user join with mobile device theme change to mobile theme.
Back
Top Bottom