The device selection (cookie or qs) always sets the device type to 'mobile'. However, when the device is 'ipad', the type should be desktop. As a solution to this, I added a types test similar to the groups test and then added support for a device string formatted like "type/group". A device switcher interface (if any is in use) should be updated to include the type in the query string.

This is backwards compatible with default groups and any custom group that did NOT include a "/". As long as there is no /, it continues to default to type = mobile.

CommentFileSizeAuthor
mt_ipad.patch3.17 KBstackpr

Comments

twom’s picture

Assigned: Unassigned » twom
Status: Patch (to be ported) » Needs work

Hi,

Thx for the patch. I have the impression that this is a more fundamental problem.
e.g. s an ipad regarded as mobile, desktop or rather tablet. Should it make sense to add the tablet type?

My take on the problem:

- When you do not configure device groups you only use: ?device=desktop, ?device=mobile, ?device=auto
Depending on the implementation of the device detecting external module, an ipad will be considered mobile or desktop. By default mobile tools detects an ipad as a desktop device.
Instead of using ?device=mobile/ipad, you just use ?device=mobile

- When you do configure device groups you use ?device=desktop, ?device=mobile, ?device=auto, ?device=
Even if iPad is seen as 'mobile', by configuring your device groups the $type variable is not used, but only the $group variable is used. So you just can use ?device=ipad. Group configurations do not care if the device is mobile or desktop, they just care about the group the device belongs too.

However, it is strange that 'type' is always 'mobile' if $_GET['device'] is something else then desktop, mobile, auto. Potentially this could be solved by adding information to the mobile_tools_device_groups():

function _mobile_tools_device_groups() {
return array('iphone'=> array('name' => 'iPhone', 'type' => 'mobile', 'ipad'=> array('name' => 'iPad', 'type' => 'desktop', ...);
} 

With this extra information, I can fill in type more correctly.

I'll keep this issue open for some time and give it some more thought.... Any argumentation welcome!

stackpr’s picture

You built the module in a nice pluggable way that allows people to create their own device types and groups. For instance, the custom module I use introduces a "console" device type that is triggered by drush commands, curl, or other command-line requests. One thing I cannot do with the current module is "?device=console" since the "?device=desktop" is hard-coded in mobile_tools. This is not too important other than that the default important behaviors need to be overridable, and focusing on that format does not let it happen. Adding a "?device=type/group" format would allow for other user-customized types and groups to be configured.

Of course, your hook_device_groups() could address the problem too as long as the type->group is one->many and not many->many. Ex: Take Opera, I might have "desktop/opera" and "mobile/opera", or "desktop/opera" and "mobile/win7-opera". Currently, I could decide which way to go in my custom detection module. Since you had 2 variables, I assumed that type and group were intended to be loosely coupled in a potentially many:many relationship that could be used however the detection module saw fit. Personally, I currently have the desktop type differentiating by browser so that I have desktop/ie6, desktop/ie7, etc., which helps with some more advanced page caching, and I might add mobile/ie* for the smart phones.

If you intend each 'group' to effectively be a 'sub-type', then the hook_device_groups() makes sense, as would a hook_device_group($group_name) to populate the results. That would centralize the configuration for the groups...

If you want to keep the structure loose, then it seems like a standard query string that specifies both type and group is the only reliable way to go, which is part of what the patch tries to do.

That felt verbose. The module is actually working quite well as-is -- not being critical. Basically, my point is that there is a use case out there where type:group is many:many, and there are types not defined in the module that currently have restricted functionality via the "?device=type" query string.

jlea9378’s picture

I'm confused by the issues I'm finding on the issue list related to the iPad. It sounds like some people would like iPad to be considered a desktop device, while others would like it to be considered a mobile device. I fall under the latter group wanting the iPad to use the mobile theme. I've selected to filter the device and use the mobile theme on /admin/settings/mobile-tools/themes, however it doesn't work. I still get the desktop theme. Does the patch on this page fix the problem?

stackpr’s picture

No. This issue relates to the override used in development. When the query string is set to device=whatever, the type is always set to mobile rather than detecting whether "whatever" should actually be a different type. The ipad was simply one of the few cases that are included in the base module that this applies to.

It sounds like you are having problems on an actual ipad versus using the dev query string, which makes yours a different issue.

twom’s picture

Status: Needs work » Needs review

@jlea9378 Look at this issue: http://drupal.org/node/1154542

I fixed the code so that if you enable the ipad as a group and select a theme, it will switch properly.

Before the ipad was detected as 'desktop' and the check on which group the device belonged too never fired...

Let me know if the current dev code solves your problem!

minoroffense’s picture

Status: Needs review » Closed (fixed)

Assuming the issue is resolved. Please reopen if that is not the case.