Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
Ive updated to the latest version, and it doesn't seem to be working.
Browsecap returns the browser details correctly, but where exactly in the code, does it tell Drupal to change its theme?
Im using D7.15.
Thanks
Comment | File | Size | Author |
---|---|---|---|
#21 | mobile_switch-hook_custom_theme-1804572-21.patch | 3.65 KB | das-peter |
#16 | mobile_switch-hook_custom_theme-1804572-16.patch | 1.58 KB | bradjones1 |
#6 | latest-version-not-working-6-6.patch | 2.79 KB | curiosity26 |
Comments
Comment #1
quiptime CreditAttribution: quiptime commentedWhat is the indicator that MSw does not work?
Comment #2
webadpro CreditAttribution: webadpro commentedIts not changing theme when viewing in either an iPhone nor a blackberry phone.
In the boot everything gets set. Although the theme is never changed even when $conf['theme_default'] is properly set. Now im wondering if its a server configuration issue. Or the function hook_custom_theme() should be used rather than the $conf file, since $conf variables can get overwritten by other modules.
Comment #3
webadpro CreditAttribution: webadpro commentedActually, i have cloned your hook_boot function and inserted as:
That seems to fix my issue. Also, i think using "hook_custom_theme" is a better solution.
Comment #4
slowflyer CreditAttribution: slowflyer commentedSame on the D6 version, theme is not switched.
Comment #5
webadpro CreditAttribution: webadpro commentedPlease don't change the Version though.
thanks
Comment #6
curiosity26 CreditAttribution: curiosity26 commentedHere is a patch that fixed the issue for us. This fixes the theme switching as well as an issue with the 'Preventing' switch being ignored. We've tested on desktop using Firefox, Chrome, IE 7/8/9, iPad, iPhone, Galaxy Tab, various Android user agents. Try it out. I hope this fixes the issue.
Comment #7
webadpro CreditAttribution: webadpro commentedI feel like hook_custom_theme should be used rather than boot, but that's maybe just me.
Comment #8
deelite CreditAttribution: deelite commentedThanks for your work!
But how can a apply this patch?
Comment #9
deelite CreditAttribution: deelite commentedOK, found that:
www.tylerfrankenstein.com/user/4/code/apply-patch-drupal-module
Had to install the package patch before.
Comment #10
curiosity26 CreditAttribution: curiosity26 commentedNo problem! My company started using Mobile Switch for Drupal 6 and found it to be the best option for mobile switching, so patching these few bugs was our contribution to you work. Thanks :)
Drupal has some good information on patches and applying patches as well: http://drupal.org/patch/apply
Git makes it much easier to create and apply patches directly to the Drupal repository.
Comment #11
quiptime CreditAttribution: quiptime commented@curiosity26,
thanks for your patch.
This is an issue reported to a branch 7.x-1+. Patches for 6.x-1+ - please create a new issue to a corresponding release.
@webadpro,
I will not abandon the use of hook_boot().
Please test MSw 7.x-1.5.
Comment #12
webadpro CreditAttribution: webadpro commentedEven though its V1, using boot isn't the proper way. Since other module such as themekey will make it impossible to make this work since it uses the hook_custom_theme which breaks this module.
I mean hook_custom_theme is the hook to use to alter a theme.
Please note I'm having the same issue with V2.
Comment #13
tsedlmeier CreditAttribution: tsedlmeier commented#3 work for me for 7.x-1.5
I think the same error is in the v2, ismobiledevice is true, but there's no switching to the mobile theme.
Comment #14
webadpro CreditAttribution: webadpro commentedMust be because of other module such as themekey conflits with this module.
Comment #15
webadpro CreditAttribution: webadpro commentedComment #16
bradjones1Some cleanup and love on this issue:
As some others have observed, this just wasn't working for me OOTB with a hook_boot() implementation, and that seems to be a less-desirable way of altering theme preference, especially if other modules wish to have a say. This module's API (limited as it is) still calls it a "boot" hook but that's easily cleaned up later if the module maintainer likes this change.
For what it's worth, I've also found the following patches are needed for proper functioning and likely block a "stable" release of 2.x:
Comment #17
bradjones1Comment #18
ykyuen CreditAttribution: ykyuen commentedHi all,
Thanks for all the suggested solutions and patches.
I have applied all 3 patched as suggested by bradjones1 in #16. but the problem is not completely resolved as i found that sometimes i need to refresh a few times of the "front" page to work. but for other pages. most of the time it could switch to mobile theme.
anyone has similar problem? the website is running on nginx with microcache enabled, not sure if that is related to the problem.
Thanks again.
Kit
Comment #19
bradjones1Kit - By needing to refresh the front page, do you mean you get some sort of error on occasion getting it to load, or bring up a cached copy, or...?
Comment #20
ykyuen CreditAttribution: ykyuen commentedthanks for the quick reply.
there is no error and i guess it is a cached page. so i wonder there maybe sth related to the nginx microcache.
i am trying to ask the hosting team to disable the microcache and see if the problem persists. will update this issue if i have any findings.
Comment #21
das-peter CreditAttribution: das-peter commentedI'm not sure if it's the best idea to use
hook_custom_theme()
only - maybe we could keep the detection inhook_boot()
to ensure the variables are set as early as possible and later use the variables inhook_custom_theme()
.But that's just an idea.
I've removed some trailing white-spaces in the patch and couldn't resist to do some other clean-up.
E.g. I didn't see to point to cast a variable (
(bool)
) and then do a typed check (===
) on it - using an untyped check without casting will give the same result.Further I didn't get the idea of having two
if
statements for something that can be easily checked in a singleif
with two conditions.Comment #22
brianbrarian CreditAttribution: brianbrarian commentedThe patch in #21 works for me to resolve a conflict with Themekey, but only after I gave Mobile Switch a higher weight than Themekey in the system table.
Comment #23
das-peter CreditAttribution: das-peter commentedI've found an issue in Drupal core that could / will affect this. I've a draft of an issue report only yet: http://dropbucket.org/node/806
I'll create a proper issue and a patch soon.
Update: Proper issue report created #2086335: Bootstrap issue with theme initialization causes hook_custom_theme() never to be invoked