There's basically four types of internet capable phones:

- Full HTML (e.g. iPhone)
- Strict XHTML (e.g. Nokia N95)
- imode (still used and popular in Asia)
- WAP (Noka 3310)

From my point of view I'd like to add the ability to further split the mobile themes. We can now only set 1 theme, meaning we have to catch every function internally using WURFL. We could make it a bit easier to develop themes, if we could separate mobile themes into these four basic groups. And set a theme for each one. A basic mobile_tools device detection script (or using wurlf) could figure out what theme to show, based on the device's user agent.

Any ideas? Its just a thought. I used to do it like this with the "accessibility" module from skiffie.com

Comments

twom’s picture

Hi,

As you will see, the mobile tools module provides a hook for other modules to detect if a user is coming from a mobile device.
I would like to extend this hook towards providing more information e.g.

hook_mobile_device_groups() {
// returns an array of device groups that the module can detect
}

the theme switching component of the mobile_tools module uses this information to present a form where you can define which theme for which devices.

hook_is_mobile_device() {
// returns what group of mobile device the visiting device belongs too
}

Is this what you are looking for?

I can already implement a basic group-detection in the mobile_tools module. I have also made a wurfl module: http://drupal.org/project/wurfl. This module can provide more groups upon which you can base your theme switching.

I am currently on holidays (starting from today ;)). So I will not be able to implement this, but I will be happy to do so when I return (5th may). Feel free to provide some patches already!

Tom

twom’s picture

Assigned: Unassigned » twom
Status: Active » Needs work
twom’s picture

Status: Needs work » Fixed

I implemented the feature where you can do theme switching based on device group.

Currently the mobile tools module natively supports: iphone', 'ipod', 'android', 'opera mini', 'blackberry'
I'll see if I can add iMode or WAP.

I implemented a new hook:

hook_device_groups() -> Third party module can provide their own implementations for providing groups.
these modules must also have the
hook_is_mobile_device() hook. This hook does the device detection and returns an array:
array('group' => 'iphone', 'type' => 'mobile') -> e.g. for iphone
array('group' => '', 'type' => 'desktop') for a desktop site.

Please test!

twom’s picture

Status: Fixed » Closed (fixed)
Anonymous’s picture

Status: Closed (fixed) » Needs work

Sorry for the extremely slow response... But I found a solution for an "official" theme switch, based on WURFL.

First of all, I propose to switch themes by official markup languages:
http://wurfl.sourceforge.net/help_doc.php#markup

These are about 14 types, which can be grouped in to the four I mentioned last year.

WML: wml_1_1, wml_1_2, wml_1_3
XHTML: html_wi_w3_xhtmlbasic, html_wi_oma_xhtmlmp_1_0
iMODE: html_wi_imode_html_1, etc.
Web: html_web_3_2 etc. (which is many Blackberrys, iPhone etc.)

In wurfl.module: add this function:

function wurfl_device_groups() {
  return array(
    'wml_1_1'=>'WML 1.1',
    'wml_1_2'=>'WML 1.2',
    'wml_1_3'=>'WML 1.3',
    'html_wi_w3_xhtmlbasic'=>'XHTML basic',
    'html_wi_oma_xhtmlmp_1_0'=>'XHTML MP',
    'html_wi_imode_html_1'=>'DoCoMo\'s iHTML 1.0',
    'html_wi_imode_html_2'=>'DoCoMo\'s iHTML 2.0',
    'html_wi_imode_html_3'=>'DoCoMo\'s iHTML 3.0',
    'html_wi_imode_html_4'=>'DoCoMo\'s iHTML 4.0',
    'html_wi_imode_html_5'=>'DoCoMo\'s iHTML 5.0',
    'html_wi_imode_htmlx_1'=>'DoCoMo\'s xHTML 1.0',
    'html_wi_imode_compact_generic'=>'cHTML',
    'html_web_3_2'=>'HTML 3.2',
    'html_web_4'=>'HTML 4');
}

Then you also have to extend the wurfl_is_mobile_device() function like this:

function wurfl_is_mobile_device() {
  $requestingDevice = wurfl_get_requestingDevice();
  $result = ($requestingDevice->getCapability("is_wireless_device") == 'true') ? 'mobile' : 'desktop'; // This is strange, return value is string, not boolean
  if ($result == 'mobile') {
    $result = array('type' => $result, 'group' => $requestingDevice->getCapability("preferred_markup"));
  }
  return $result;
}

You have 13 theme options, but with 4 themes you can cover them all: WML, XHTML, IMODE, WEB (full html)

I also noticed a bug in WURFL.module:
return $requetingDevice->getCapability($capability);
should be
return $requestingDevice->getCapability($capability); +t

I also have a suggestion: allowing SPECIFIC targeting of a device. For example, allow adding custom themes for only iPhone V3 etc. That should be easy with WURFL integration: simple match a (groupp of) User Agents with a theme group. For now I'm satisfied, but imagine the marketing power! You could target specific ads blocks to iPhone v3 only.

@twom: Maybe you can add this to the WURFL module?

minoroffense’s picture

Status: Needs work » Closed (won't fix)

1.x is no longer supported