Mobile Detect implementation for Statamic CMS
JavaScript PHP Shell
Permalink
Failed to load latest commit information.
Mobile-Detect @ 7a94b34
tests_casperjs rearrange some deck chairs Aug 7, 2015
.editorconfig
.eslintrc
.gitignore
.gitmodules
LICENSE.txt
README.md
package.json
pi.mobile_detect.php
run_test.sh
statamic-logo.png

README.md

Statamic CMS Logo

Statamic Mobile Detect Plugin

Statamic 1.9-1.11.1 + Mobile Detect 2.8.17

This plugin could not exist without the amazing work of the Mobile Detect project Mobile Detect 2.8.17

Installing via git

  1. Clone the repo via git into /_add-ons/.

    cd _add-ons/
    git clone git@github.com:haikulab/statamic-mobile-detect.git mobile_detect
    
  2. Pull in the Mobile Detect repository using git submodules

    cd mobile_detect/
    git submodule init
    git submodule update
    

You should see something like this:

    → git submodule init
    Submodule 'Mobile-Detect' (git://github.com/serbanghita/Mobile-Detect.git) registered for path 'Mobile-Detect'

    → git submodule update
    Cloning into 'Mobile-Detect'...
    remote: Reusing existing pack: 1712, done.
    remote: Total 1712 (delta 0), reused 0 (delta 0)
    Receiving objects: 100% (1712/1712), 1.94 MiB | 596.00 KiB/s, done.
    Resolving deltas: 100% (825/825), done.
    Submodule path 'Mobile-Detect': checked out 'd6943b36f45a9ee654e87cd98832890797a228fb'
  1. Ensure the plugin-in folder name is mobile_detect (and not statamic-mobile-detect).

    mv statamic-mobile-detect mobile_detect
    
  2. Clear the Statamic cache - How to clear the cache

  3. Use the tags listed in Usage.

Usage

Core Tag

{{ mobile_detect }}

Example Output for {{ mobile_detect }}

  • computer
  • tablet
  • phone

Get Mobile Detect library version number

{{ mobile_detect:library_version }}

Example Output for {{ mobile_detect:library_version }}

2.8.17

Using as part of logic

Using {{ mobile_detect }} as part of an {{ if }} statement:

{{if something == { mobile_detect } }}
    ...
    {# some content #}
    ...
{{ endif }}

Tested on

  • Statamic 1.9.0-1.11.1

Disclaimer

I've 'written' this plugin for my own use. It comes without any guarantee, so your mileage may vary in using it. If you find bugs or have great additions you'd like to share, use github to fork the project and share your improvements by initiating pull request

MIT License

Copyright (c) 2014 Sergei Filippov

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.