Coder Social home page Coder Social logo

meerware-browser-information's Introduction

Browser Information for SilverStripe

A small module for detecting the browser name, version, operating system and device type through the browser user agent and exposing methods for controllers.

Requirements

  • SilverStripe 3 or higher

Usage

The module automatically extends all Controllers to have two methods:

$controller->getBrowser();
$controller->Browser();

Both returning a Browser class which wraps the browser name, version, operating system and device type.

Browser Name

$browser->getName();

The browser name is crude but will return one of the following:

  • ie
  • firefox
  • chrome
  • safari
  • netscape
  • opera
  • konqueror
  • unknown

Browser Version

$browser->getVersion();

The browser version will return a string value in the format of "X.X", just the major and minor version numbers if present.

Operating System

$browser->getSystem();

The operating system will return one of the following values:

  • linux
  • macintosh
  • windows
  • ios
  • android
  • unknown

Device

$browser->getDevice();

Device detects whether the browser is either a handheld or a screen device (mobile/tablet or desktop/laptop) and will return the following values:

  • screen
  • handheld

Engine

$browser->getEngine();

Detects the browser rendering engine and will return the following values:

  • gecko
  • webkit
  • trident
  • presto

Templates

When the module is included in your SilverStripe directory structure, the module, through extension, will expose a browser attribute for use in templates:

<html class="$Browser">

Will be evaluated to something like:

<html class="macintosh firefox firefox22 screen gecko">

meerware-browser-information's People

Contributors

meerware avatar

Watchers

James Cloos avatar helpfulrobot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.