2017 © Pedro Peláez
 

symfony-bundle mobile-detect-light-bundle

Symfony2 bundle for easy usage of mobiledetect class in Twig http://mobiledetect.net/

image

thormeier/mobile-detect-light-bundle

Symfony2 bundle for easy usage of mobiledetect class in Twig http://mobiledetect.net/

  • Monday, March 31, 2014
  • by thormeier
  • Repository
  • 1 Watchers
  • 2 Stars
  • 6,049 Installations
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

MobileDetectLightBundle

Build Status, (*1)

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., (*2)

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:, (*3)

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 %}

The Versions

31/03 2014

dev-master

9999999-dev

Symfony2 bundle for easy usage of mobiledetect class in Twig http://mobiledetect.net/

  Sources   Download

MIT

The Requires

 

The Development Requires

by Pascal Thormeier
by Boris Hofer

31/03 2014

1.0.4

1.0.4.0

Symfony2 bundle for easy usage of mobiledetect class in Twig http://mobiledetect.net/

  Sources   Download

MIT

The Requires

 

The Development Requires

by Pascal Thormeier
by Boris Hofer