Last updated June 18, 2012. Created by twom on May 11, 2009.
Edited by minorOffense, shamio, LewisNyman, John Bickar. Log in to edit this page.

This page contains the documentation for the Mobile Tools module.

Introduction

Mobile Tools helps you in creating a mobile website. In short, the functionality provided is:

  1. Detection of a mobile device
  2. Pluggable approach to get device detection functionality from other modules
  3. Redirect mobile users to a mobile url
  4. Switch themes based on device or device group
  5. Contrib modules can provide device groups
  6. Creating permissions for mobile users (experimental and not recommended)

Mobile Tools also provide plugins for Panels and Node Display . In order to use Node Display, you have to enable the "Mobile Tools build mode" in the configuration. You can use build modes to have different imagecache presets for your nodes, or hide/display content based on the mobile context.

Some considerations

Several approaches exist in order to go Mobile.

Mobile Tools allows you to configure these settings.

Download and installation of the module

Follow the general general installation instructions to install Mobile Tools.

Using third party modules

The mobile tools module consist of two core algorithms that can be taken over by other modules:

Device Detection modules

If a module is able to detect if a visiting device is mobile, it can implements the hooks
hook_device_groups() and hook_is_mobile_device().

The hook_device_groups() returns a list of device groups the module can distinguish. The Mobile Tools module has the following implementation:

function mobile_tools_device_groups() {
  return array('iphone', 'ipod', 'android', 'opera mini', 'blackberry');
}

the hook_is_mobile_device() must return an array of the form
array('type' => $type, 'group' => $group). $type can be mobile or desktop and $group must equal on of the elements returned by the hook_device_groups.

The reason for this hook is the presence of commercial providers of this information and the popularity of WURFL. Mobile Tools gives a basic implementation.

Site type detection

If 1 Drupal installation is used for both the mobile and the desktop site, there is a need for a mechanism to detect if the Drupal site is being mobilized or not. This is needed to decide if redirection is necessary, and allows mobile users to visit the desktop site.

Device capability detection (advanced usage for developers)

The Mobile Tools module currently doesn't provide information on the device characteristics such as screen size, browser capabilities, javascript support, etc ...
Different services exist that can provide this information (e.g. WURFL). In order to help developers to easily change provider of this information, the Mobile Tools module provides a generic interface to query device capability information.

In order to use this function you have to install at least one module with this capability. (e.g. WURFL).

device capabilities can be queried by calling:
mobile_tools_devicecapability($capability). Capability is a property of the device. For a list of properties, take a look at the WURFL documentation (http://wurfl.sourceforge.net/help_doc.php. )

Force the user to see a specific version of the site

Forcing the visiting device to be recognized as a certain device can be useful when showcasing your site on a desktop browser, or to let the visitor choose which version he wants to see. You can force the theme by using the ?device_group=... query parameter>it can take the following values:

  • ?device=desktop => force the the device to be recognized as desktop
  • ?device=mobile => force the the device to be recognized as mobile
  • ?device=[device_group] => force the the device to be recognized as the specified device group
  • ?device=auto => reset everything and enable the normal behavior

Each time a ?device parameter is set, the value will be remembered by setting a cookie.

The ?nomobile=true functionality that was available in previous versions has been removed.

Persist sessions between mobile and desktop site

Read this blogpost for a more detailed description on this subject.

Caching

When you use 1 url for different themes, normal caching in Drupal will serve the page that is cache and bypass the theme switching.

See the mobile_tools_cache.inc file for instruction on enabling caching.

Feedback and Help

Feedback, reports and bugs can be reported on the Mobile Tools project page: Mobile Tools

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

the domain module http://drupal.org/project/domain might help with this as well though most of it's features are seen here.
But one things it makes easy to do is have multiple domains for the same site use different home pages, urls etc.
So I for example made a http://m.example.com/mobile View and then used the Domain module point to it and use a different theme.

Seems though your write up and the mobile module takes care the of the theme switching well.

Absolutely terrific module! Works flawlessly from the start. I am still a little unclear about what YouTube optimization does but I will try to figure it out. Thanks a million for your hard work!

thank for this module! is excellent.

The Mobile Tools module is essential in the solution I have created for my Drupal 6 sites. These sites are part of a multi-site (single code-base/separate databases) configuration. But the solution works also for a single site set-up.
The mobile devices are served from the separate subdomain m.example.com.
The solution works for sites that are cached with the Boost module.

Besides Mobile Tools, the solution uses Domain Access, Domain Meta Data and Nodewords modules. A small modification to the Nokia Mobile theme allows to use canonical URLs for SEO purpose on the mobile pages.

After I implemented the solution I documented it here as a tutorial:
http://www.drupalinternetbusiness.com/content/drupal-6-mobile-site-tutor...

There you can also find the modification that is needed for your htaccess file to make it all work.

Thanks to Mobile Tools for helping me to make the Drupal 6 sites mobile in the best possible way.