2017 © Pedro Peláez
 

contao-bundle contao-mobiledetection-bundle

Contao 4 helper class for detecting mobile phones and tablets (device type). A Hook adds a CSS class in the body tag.

image

bugbuster/contao-mobiledetection-bundle

Contao 4 helper class for detecting mobile phones and tablets (device type). A Hook adds a CSS class in the body tag.

  • Wednesday, February 14, 2018
  • by BugBuster
  • Repository
  • 1 Watchers
  • 0 Stars
  • 68 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 143 % Grown

The README.md

Contao 4 Bundle "Mobile-Detection"

Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

Codacy Badge, (*2)

About

Contao 4 Bundle "Mobile-Detection", based on "http://mobiledetect.net/", (*3)

Helperclasses for developer. Demo frontend module is present., (*4)

Installation

With Contao Manager

With Composer

  • composer require bugbuster/contao-mobiledetection-bundle
  • Composer loads additionally "mobiledetect/mobiledetectlib" version 2.*

Hooks help!

A Hook add a special class to page css class (in body tag):, (*5)

  • phone : mobile device, but no tablet
  • tablet : mobile device and a tablet
  • computer : no mobile device, no tablet

Examples

Galaxy S II (Phone), (*6)

  • <body id="top" class="android safari webkit sf4 mobile phone">

Motorola Xoom (Tablet), (*7)

  • <body id="top" class="android safari webkit sf3 mobile tablet">

Linux Mint PC (Computer), (*8)

  • <body id="top" class="unix firefox gecko fx18 computer">

Usage the Classes

You have two options:, (*9)

  • You're using the original class (Detection\MobileDetect).
  • You're using the wrapper class (BugBuster\MobileDetection\Mobile_Detection).

Mobile_Detect (original class)

Composer version (with a namespace of the original class)

use Detection\MobileDetect;

$detect = new MobileDetect(); 

// Check for any mobile device.
if ($detect->isMobile())

// Check for any tablet.
if($detect->isTablet())

// Check for any mobile device, excluding tablets.
if ($detect->isMobile() && !$detect->isTablet())

For the full list of available methods check the directory examples., (*10)

Mobile_Detection (wrapper class)

use BugBuster\MobileDetection\Mobile_Detection;
...
$this->Mobile_Detection = new Mobile_Detection();

// Check device type
echo $this->Mobile_Detection->getDeviceType(); // phone|tablet|computer

// Check for any mobile device.
if ($this->Mobile_Detection->isMobile())

// Check for any tablet.
if ($this->Mobile_Detection->isTablet())

// Check mobile grade
echo $this->Mobile_Detection->getMobileGrade(); // A|B|C

// Check mobile rules
$arrRules = $this->Mobile_Detection->getMobileRules(); 
// result e.g. array('SamsungTablet','AndroidOS','Safari')

See demo module "MobileDetectionDemo"., (*11)

The Versions

14/02 2018

dev-master

9999999-dev http://contao.ninja

Contao 4 helper class for detecting mobile phones and tablets (device type). A Hook adds a CSS class in the body tag.

  Sources   Download

LGPL-3.0-or-later

The Requires

 

The Development Requires

contao mobile phone tablet detection

13/02 2018

1.0.1

1.0.1.0 http://contao.ninja

Contao 4 helper class for detecting mobile phones and tablets (device type). A Hook adds a CSS class in the body tag.

  Sources   Download

LGPL-3.0-or-later

The Requires

 

The Development Requires

contao mobile phone tablet detection

13/02 2018

1.0.0

1.0.0.0 http://contao.ninja

Contao 4 helper class for detecting mobile phones and tablets (device type). A Hook adds a CSS class in the body tag.

  Sources   Download

LGPL-3.0-or-later

The Requires

 

The Development Requires

contao mobile phone tablet detection