Mobile Device capability detection: new Drupal module using WURFL

Today I released a first version of my WURFL wrapper module for Drupal. It provides an API for developers / themers in order to detect what device is accessing the site and also to see what the capabilities are of the device (e.g. screen site, support for ajax, which device, touch_screen, etc ...).

At Siruna we use WURFL (among other techniques) extensively to adapt websites to the mobile devices. This includes image transcoding, html and CSS cleanup, usability improving, javascript handling, etc ...

Having technologies that detect device capabilities, allows you to make adaptive and context sensitive websites. Currently device fragmentation is really a big pain for developers who are dedicated to making quality mobile web sites.

Short intro to WURFL

In short, WURFL is an open-source project hosted on, with the goal of creating an XML file containing all possible mobile devices and their capabilities. This xml file (called wurfl.xml) can be downloaded from This file is getting updates regularly when new devices are added, or bugs are found. Updating the module means getting the latest wurfl version from the project page.

An overview of all capabilities that can be detected using WURFL can be found here:

WURFL is being used by mobile application developers and mobile web developers in order to create adaptive websites, that run well on as much devices as possibilities.
So now it is accessible for Drupal developers too :)


Usage is very simple. Just call

With $capability a string containing the capability you want information about. All the capabilities and the return values can be found at

e.g. wurfl_devicecapability('xhtml_make_phone_call_string') returns the string you have to use to make a phone number clickable in the browser.

If you download the Mobile Tools module, you could use the more generic call:

This function will dispatch your call to the module of choice that will return the capability. Currently only a wurfl implementation is available. But more implementation can be foreseen in the future:
(e.g., or even Siruna.)

WURFL PHP library

As already mentioned. The module I initiated is just a wrapper for the more extensive PHP library that is already provided in the WURFL project. All the intelligence sits in that module:

In order to get the drupal module running, you need to download the WURFL php library and instsall it in the /lib directory of the module.

The PHP library also contains a configuration file that defines the location of the wurfl.xml file and the cache directory (wurfl-config.xml). Read the INSTALL.txt file too see what changes are needed. Please give feedback on your installation process.


I need more testing to see how performant the WURFL library is. It uses caching mechanismes or can be used in combination with, Memcache, APC, EAccelerator, RDBMS, .... Since the wurfl.xml file is very big, the PHP library uses some techniques that reduce the memory load.

In order to use different caching mechanismes you need to delve into the wurfl-config.xml file, located in the resources directory.

In future updates, I'll take more care on performance at the side of the wrapper module.

I would be happy to take questions on the module or implement some new features. Just let me know if you have some successful implementations using the WURFL module.

If things get too complicated, just try together with the Mobile Tools module to generate a mobile website!!