Mobile Detect uses a lightweight PHP class (Mobile_Detect) for detecting mobile devices (including tablets).
Designed for use with ProcessWire 2.4/2.5 http://processwire.com
- Clone the module and place MobileDetect in your site/modules/ directory.
git clone https://github.com/justonestep/processwire-mobiledetect.git your/path/site/modules/MobileDetect
- Login to ProcessWire admin and click Modules.
- Click "Check for new modules".
- Click "install" next to the new SimpleContactForm module.
This Module extends $config
and sets the following parameters:
$config->mobileDetect = array(
'deviceType' => 'deviceType (phone, tablet or desktop)',
'browser' => 'mobile browser',
'operatingsystem' => 'mobile operatingsystem',
'device' => 'mobile device'
);
You can access them where ever you want.
See the example below:
<body class="devicetype--<?php echo $config->mobileDetect->deviceType?>">
<body class="devicetype--{{config.mobileDetect.deviceType}}"> // twig
Results in:
<body class="devicetype--phone"> OR
<body class="devicetype--tablet"> OR
<body class="devicetype--desktop">