Introducing: 'Kirby Device'


#1

Hey there,
when I first stumbled across @texnixe’s kirby-mobile-detect, I loved it - but sadly, it seemed that the underlying Mobile-Detect library wasn’t actively developed anymore.

As time went by, I stumbled across Matomo’s (formerly known as Piwik) DeviceDetector and decided to make a Kirby plugin out of it. This is still an early version and a work in progress, but apart from missing options which I will include in a later release (eg file caching of results, Kirby-style), it’s fully operational.

So check it out, stay tuned and let me know what you think!

Cheers.


Different Snippet per Breakpoint
#2

Update

Hey again, I just added a list of all available methods & finished version truncation, see below. This should make working with kirby-device easier.

Attention: Caching & custom YAML parser coming soon!

Configuration

Change kirby-device options to suit your needs:

Option Type Default Description
plugin.kirby-device.truncate-version String minor Defines the browser build or version format according to the semantic versioning specification (allowed values are major, minor, patch as well as build & none).
plugin.kirby-device.enable-filecache Boolean true Optionally enables / disables filecache.

Available methods

These methods are available to meet your device detection requirements:

// Configuration Methods
setCache()
setYamlParser()
discardBotInformation()
skipBotDetection()

// General Device Type Methods
isBot()
isMobile()
isDesktop()
isTouchEnabled() // win8 tablets only

// General Client Type Methods
getBot() // array
getClient() // array | optionally string, eg getClient('version'))
getOs() // array | optionally string, eg getOs('version')
getDevice()
getDeviceName()
getBrand()
getBrandName()
getModel()
getUserAgent()

// Specific Device Type Methods
isSmartphone()
isFeaturePhone()
isTablet()
isPhablet()
isConsole()
isPortableMediaPlayer()
isCarBrowser()
isTV()
isSmartDisplay()
isCamera()

// Specific Client Type Methods
isBrowser()
isFeedReader()
isMobileApp()
isPIM()
isLibrary()
isMediaPlayer()

Unless stated, all isSomething() methods return booleans, all getSomething() methods return strings.


#3

Releasing v0.2.0

Caching has finally landed and is performed by Doctrine’s caching component. Have fun, of course feedback is welcome as always.

Cheers!


#4

Thanks a lot, I’ll try it !


#5

kirby-device may now be installed through Composer.
Furthermore, piwik/device-detector on branch master was updated to v3.10.1 (see ‘changelog’).