Summary: Function to determine whether the current browser is a mobile device.
Version: 23-Apr-2012 (0.0.1)
Prerequisites: None
Status: Active
Maintainer: XES
Categories: Mobile, PDA, Cookbook
Users: (View? / Edit)


Allows PmWiki to detect whether the browser viewing the wiki is on a mobile device. May be used within PmWiki (or PHP in general) to load mobile specific skins, change items within a webpage based on whether the page is viewed on a mobile device, or perform other mobile-related actions.

Download and Installation

  1. Download the script. (Download: detectmobilebrowsers.phpΔ)
Warning: the script contains some long lines, so if you open it in a text editor, be sure not to save the files with word-wrap on.
  1. Unzip it into your cookbook directory (usually pmwiki/cookbook/).
  2. Add the following to your local configuration file:

Using the Script

Simply call the function from within PHP:


For example, you might use it in config.php to use a different skin if a mobile device is detected.

if (detect_mobile_device()) {
   $Skin = 'skidoo/PDA';
} else {
   $Skin = 'skidoo';

You might also use it in config.php to allow features in a webpage that change on a mobile device AND to change the skin if a mobile device is detected (example skin is the MobileSkin?):

if (detect_mobile_device()) {
   $Skin = 'mobile';
   $FmtPV['$isMobile'] = '"true"';
} else {
   $Skin = 'pmwiki';
   $FmtPV['$isMobile'] = '"false"';

Now within a webpage you can use: (:if {$isMobile}:) and (:if !{$isMobile}:) markups.

Known Issues

  • Out of the box, this plug-in ignores tablet devices. This is deliberate.

Change Log

23-Apr-2012 (0.0.1)

Contributors: XES & ChrisK

  • wrapped Chad Smith's mobile device plug-in in a function, ready for PmWiki use.
  • First release.


  • Mobile device detection is based on Chad Smith's unlicensed/free PHP script available from There may be updates at the originator's website as new mobile browsers & device architectures are released.
  • Credit to DetectMobile & DaveG, without whom I may not have ever thought to have a mobile browser/skin for PmWiki in the first place.


See discussion at DetectMobileFree-Talk

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.