Resource icon

xF2 Add-on Browser Detection 2.3.1

No permission to download
Compatible XF Versions
  1. 2.0
  2. 2.1
  3. 2.2
A light-weight shim around Mobile_detect for XenForo 2

Usage (in templates)

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


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


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


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

Usage (in php)

Code:
$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;

Code:
$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
Admin
Size
41.6 KB
Extension
zip
Downloads
22
Views
2,659
First release
Last update

More resources from Admin

Latest updates

  1. Browser Detection 2.3.1

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

    This add-on is now available on atelieraphelion.com Require XenForo 2.2+ Require php 7.2+...
  3. 2.2.0 - Feature/Maintenance update

    Implement caching wrapper around Mobile_detect::match calls. Forward unknown function calls to...

Similar resources

Allows you to specific page criteria using when using Xon's Browser Detection addon.
[XTR] Browser Title Bar Animation Admin
Grab the users’ attention and take them back to your shop/website and reduce site abandonment.
731Threads
2,287Messages
63,841Members
Precaution InternetLatest member
Back