I tried using the 6.x beta version of this module and there's an issue in the hook_boot() that will prevent this module from doing what it's supposed to do - that is, to switch to a mobile theme on a mobile device. I looked at the 7.x version and this issue looks partially fixed.
I'm seeing two issues:
1) When a mobile device is detected, we're setting "theme_default" to "mobile_switch_theme_default". This is incorrect. It should be set to "mobile_switch_theme_mobile". Looks like this is fixed in 7.x.
2) Browscap returns a string for 'ismobiledevice', not a boolean. The check for "(bool) $get['browser']['ismobiledevice'] === TRUE" will be TRUE even if $get['browser']['ismobiledevice'] is equal to 'false' as a string, because then you run it through the bool function. ((bool) "false") will equal TRUE. In general, there seems to be an overuse of the bool() function. I've decided to fix this by keeping the 'ismobiledevice' value as a string -- so when you check for the emulator, I've set that value to 'false' or 'true' as a string also. The way it was written, 'ismobiledevice' would have been 0 or 1 if working with an emulator, and 'false' or 'true' if working with an actual mobile device.
Patch will be attached.
Comment | File | Size | Author |
---|---|---|---|
#3 | mobile-theme-switching-not-working-1810326-3.patch | 1.96 KB | djbobbydrake |
#1 | mobile-theme-switching-not-working-1810326-1.patch | 2.41 KB | djbobbydrake |
Comments
Comment #1
djbobbydrake CreditAttribution: djbobbydrake commentedPatch attached.
Comment #2
djbobbydrake CreditAttribution: djbobbydrake commentedRequesting review for the patch.
Comment #3
djbobbydrake CreditAttribution: djbobbydrake commentedModified the patch in comment #1 to remove the unnecessary changes to the .info file.
Comment #4
jorlowski CreditAttribution: jorlowski commentedPatch applied from #3. Still a no-go. Tested on iPhone.
Comment #5
djbobbydrake CreditAttribution: djbobbydrake commented@jorlowski If you view your site on Firefox using the User Agent Switcher Add-on to spoof an iPhone, do you get your mobile theme? This has been working for us., via emulator, user agent spoofing, as well as on iPhone and Android. Can you see what your values are for $conf['mobile_switch_theme_default'], $conf['mobile_switch_theme_mobile'], and $conf['theme_default'] on the page that's supposed to see the mobile theme?
Comment #6
jorlowski CreditAttribution: jorlowski commentedViewing the site in Firefox using the User Agent Switcher Add-on spoof I still get the desktop theme "Garland" (I'm only using this theme for testing). As of now I am using "Bluemarine" as the mobile theme for testing purposes only. I've tested on both iPhone and HTC EVO 3D handsets and both default to the desktop version.
I do get the mobile theme (Bluemarine) when I select "yes" under Desktop browser in the Development menu. This was only for a test to see if anything was actually working.
Also, I am not a noob but not a developer. Can you direct me via file name to where I'll be able to find $conf['mobile_switch_theme_default'], $conf['mobile_switch_theme_mobile'], and $conf['theme_default']?
Comment #7
darktiger CreditAttribution: darktiger commentedpatch #3 does not work also on Samsung S3 neither with google browser, firefox nor opera mobile.
Comment #8
webadpro CreditAttribution: webadpro commentedLooking at the following issue might help: http://drupal.org/node/1804572
Comment #9
quiptime CreditAttribution: quiptime commentedPlease test your theme switch problem with 6.x-1.x-dev.
Give me feedback.
Coming soon release 6.x-1.0-beta2 which contains the latest changes from dev.
Comment #10
dshields CreditAttribution: dshields commentedAny progress on this?
i can't get this module to work on my drupal 6 site, testing with iPhone4
Comment #11
stoogiebuncho CreditAttribution: stoogiebuncho commentedUsing the 6.x-1.x-dev version of the module seems to fix the problem for me.