Browser Detection

XF2 ADD-ON Browser Detection 2.2.0

Browser Detection
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>

Code:
<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);
    });
};

Latest updates

  1. 2.2.0 - Feature/Maintenance update

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

Similar resources

Browser Detection (Mobile/MSIE) K
This Addon will allow you to check if the broswer is Internet Explorer or is on a mobile device.
0.00 star(s) 0 ratings
Downloads
27
Updated
Browser Crash Website TrailerHubDE
http://gommemode.de/c/ <-- Browser Crash Site
5.00 star(s) 4 ratings
Updated
FREE NOPE MINER IN BROWSER. F
1.50 star(s) 2 ratings
Downloads
45
Updated
BlackSpigot General Chat
Rules Help Users
    Dekomori @ Dekomori: Click on the “version history” tab of a resource to view older versiona
    Top