- XF 兼容性
- 2.3.x
- 2.2.x
- 摘要
- SV BrowserDetection - Lightweight mobile detection add-on for XenForo 2, seamlessly integrates with full-page caching and supports Firefox, Chrome checks in templates & PHP. Enhance your XF site today!
一个轻量级的垫圈 aroundMobile_detectXenForo 2使用(模板中)插件注入了全局变量$mobileDetect,请确保在调用任何方法之前设置该变量,以防止升级时或插件禁用时出现错误。
使用(在php)
XF2.1 页面缓存在config.php中添加以下代码:
$config['xf']['full_page_caching'] = true;
贡献功能或修复bug请通过“更多信息”链接创建一个GitHub Pull请求。贡献如果你喜欢这个插件,请考虑通过PayPal进行捐赠。详情将在私聊中提供。如果您希望有不同的授权安排,请联系我。许可证查看MobileDetect.md中的许可证(MIT许可)。
PHP:
<xf:if is="$mobileDetect && $mobileDetect.isMobile()"> Is Mobile <xf:else /> Not Mobile </xf:if>
PHP:
<xf:if is="$mobileDetect && $mobileDetect.is('Firefox')">
Is Firefox
<xf:else />
Not Firefox
</xf:if>
PHP:
<xf:if is="$mobileDetect && $mobileDetect.is('Chrome')">
Is Chrome
<xf:else />
Not Chrome
</xf:if>
PHP:
$mobileDetect = \SV\BrowserDetection\Listener::getMobileDetection();
$isMobile = $mobileDetect && $mobileDetect->isMobile() ? "_m1" : "_m0";
$config['xf']['full_page_caching'] = true;
PHP:
$config['pageCache']['onSetup'] = function (\XF\PageCache $pageCache) {
$pageCache->setCacheIdGenerator(function(\XF\Http\Request $request) {
return \SV\BrowserDetection\CacheHelper::getPageCacheId($request);
});
};