thormeier/mobile-detect-light-bundle
Composer 安装命令:
composer require thormeier/mobile-detect-light-bundle
包简介
Symfony2 bundle for easy usage of mobiledetect class in Twig http://mobiledetect.net/
README 文档
README
Introduction
This Symfony2 bundle provides three twig functions to check if the client is on a mobile or tablet device. This bundle makes use of the class provided by http://mobiledetect.net/. This bundle is built to be as lightweight as possible to provide a possibility to alter Twig templates according to the clients device.
Installation
Step 1: Composer require
$ php composer.phar require "thormeier/mobile-detect-light-bundle":"1.0.*"
Step2: Enable the bundle in the kernel
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Thormeier\MobileDetectLightBundle\ThormeierMobileDetectLightBundle(),
// ...
);
}
Usage
There are three new Twig functions provided by this bundle:
is_mobile()
// template.html.twig
{% if is_mobile() %}
{# do something that is only visible for mobile users, i.e. display an app store button or similar #}
{% endif %}
is_tablet()
// template.html.twig
{% if is_tablet() %}
{# do something for tablet users only #}
{% endif %}
is_desktop()
// template.html.twig
{% if is_desktop() %}
{# do something for desktop users only #}
{% endif %}
统计信息
- 总下载量: 6.07k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-03-31