leowebguy / device-detect
Craft plugin for detecting devices, OS, bots and more
Installs: 5 088
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 1
Type:craft-plugin
Requires
- php: ^8.2
- craftcms/cms: ^5.0
- mobiledetect/mobiledetectlib: ^4.8
Requires (Dev)
- craftcms/ecs: dev-main
- craftcms/phpstan: dev-main
- craftcms/rector: dev-main
- laravel/pint: ^1.14.0
README
Detect devices, OS, bots and more
Wrapper around MobileDetect by @serbanghita
Installation
Open your terminal and go to your Craft project:
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:
{{ craft.deviceDetect.isMobile ? 'I am mobile.' : 'I am not mobile.' }}
Devices
{{ craft.deviceDetect.isMobile }} {{ craft.deviceDetect.isTablet }} {{ craft.deviceDetect.isiPad }} {{ craft.deviceDetect.isPhone }}
OS
{{ 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