If a custom theme is set for the iPad, Mobile Tools won't switch to that theme. The iPad's device type is set as a "desktop" which doesn't allow it to switch themes. Setting the device type for the iPad to "mobile" allows for a custom theme, but then sets the default theme to your mobile theme, instead of the desktop theme.
The solution appears to be to allow for "desktop" device types to have custom themes, but I don't know if will cause other problems within the module. This is what I did to fix the issue for myself.
function mobile_tools_switch_theme($device) {
global $custom_theme, $conf;
// check if theme switching is forced
$current_url_type = mobile_tools_site_type();
if (($current_url_type == 'mobile' && variable_get('mobile-tools-theme-switch', '' ) == 'mobile-tools-mobile-url') || (variable_get('mobile-tools-theme-switch', '' ) == 'mobile-tools-mobile-device' && $device['type'] == 'mobile') ) {
$group = $device['group'];
$mobile_detection_module = variable_get('mobile-tools-device-detection', 'mobile_tools');
if (variable_get($mobile_detection_module . '_' . $group . '_enable', '') == 1) {
$custom_theme = variable_get($mobile_detection_module . '_' . $group . '_theme', $conf['theme_default']);
return $custom_theme;
}
else {
$custom_theme = variable_get('mobile_tools_theme_name', $conf['theme_default']);
return $custom_theme;
}
} else {
// Allow custom themes for 'desktop' device types
$group = $device['group'];
$mobile_detection_module = variable_get('mobile-tools-device-detection', 'mobile_tools');
if (variable_get($mobile_detection_module . '_' . $group . '_enable', '') == 1) {
$custom_theme = variable_get($mobile_detection_module . '_' . $group . '_theme', $conf['theme_default']);
return $custom_theme;
}
}
return FALSE;
}
Comments
Comment #1
taz88ny commentedI have created a patch for my change in the original post.
Comment #2
taz88ny commentedComment #5
twom commented@taz88ny
Thx for the patch. I cannot apply at this point, because I have had requests too to not switch themes for ipads.
It seems that I would need to add a second category (tablet).
In meantime, you can always write a small contrib module that defines your device groups:
http://www.mobiledrupal.com/content/create-your-own-device-detection-alg...
Comment #6
twom commentedComment #7
taz88ny commented@twom
The change that I made doesn't actually make the iPad a mobile device. It just allows desktop devices to have custom themes. On the "Theme Switching" page of the admin (/admin/config/system/mobile-tools/themes), the user has to option to choose a specific theme for the iPad. The problem was the picking a custom theme for the iPad didn't work because the iPad was considered a desktop and desktops couldn't have custom themes.
That just a long way of saying that with this patch, the iPad can now have a custom theme, but it will still default to the desktop theme if nothing is selected.
Comment #8
jlea9378 commentedCan this patch be applied to 6.x-2.3? I've had requests for setting the mobile theme on iPad to work.
Comment #9
twom commented@taz88ny
I applied the patch! The lateste dev version has some additional changes in the creation of "full site" / "mobile site" urls. I hope you can test and give feedback.
Best clear cache after getting the new dev version!
Thanks for the work!!
PS: I was to fast in my commit message, I will try to see if I can edit the commit message to attribute your patch! ;)
Comment #10
minoroffense commentedAssuming the issue is resolved. Please reopen if that is not the case.