https://github.com/leowebguy/devicedetect
https://github.com/leowebguy/devicedetect
craft-plugin craftcms
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/leowebguy/devicedetect
- Owner: leowebguy
- Created: 2022-05-30T15:20:29.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-11-22T15:58:10.000Z (over 1 year ago)
- Last Synced: 2025-11-13T20:27:13.114Z (7 months ago)
- Topics: craft-plugin, craftcms
- Language: PHP
- Homepage:
- Size: 17.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Device Detect plugin for Craft
### Detect devices, OS, bots and more
Wrapper around [MobileDetect](http://mobiledetect.net/) by [@serbanghita](https://github.com/serbanghita)
## Installation
Open your terminal and go to your Craft project:
```bash
composer require leowebguy/device-detect -w && php craft plugin/install device-detect
```
## Usage
The plugin exposes most of MobileDetect's methods, and can be used in your Twig:
```twig
{{ craft.deviceDetect.isMobile ? 'I am mobile.' : 'I am not mobile.' }}
```
Devices
```twig
{{ craft.deviceDetect.isMobile }}
{{ craft.deviceDetect.isTablet }}
{{ craft.deviceDetect.isiPad }}
{{ craft.deviceDetect.isPhone }}
```
OS
```twig
{{ craft.deviceDetect.isiOS }}
{{ craft.deviceDetect.isiPadOS }}
{{ craft.deviceDetect.isAndroidOS }}
User agent
```twig
{{ craft.deviceDetect.getUserAgent }}
```
getUserAgent returns string i.e. _Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36_