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;
}
CommentFileSizeAuthor
#1 theme_switching-1154542.patch783 bytestaz88ny

Comments

taz88ny’s picture

StatusFileSize
new783 bytes

I have created a patch for my change in the original post.

taz88ny’s picture

Assigned: Unassigned » taz88ny
Status: Active » Needs review
twom’s picture

@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...

twom’s picture

Category: bug » feature
taz88ny’s picture

@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.

jlea9378’s picture

Can this patch be applied to 6.x-2.3? I've had requests for setting the mobile theme on iPad to work.

twom’s picture

@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! ;)

minoroffense’s picture

Status: Needs review » Closed (fixed)

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