This patch uses Browscap to detect the browser, and then change the theme based on what browser they're using. It only allows the functionality if the Browscap module is enabled.....
You'll need browscap for Drupal 6.
| Comment | File | Size | Author |
|---|---|---|---|
| #25 | switchtheme_with_browscap_patch.zip | 14.01 KB | srinikasturi |
| #12 | switchtheme_D5_browscap.patch | 5.97 KB | jameselkins |
| #10 | switchtheme_D5_browscap.patch | 4.74 KB | jameselkins |
| #9 | switchtheme_D5_browser.patch | 8.08 KB | jameselkins |
| #2 | switchtheme-DRUPAL-6--1.browscap.patch | 7.01 KB | sun |
Comments
Comment #1
robloachOops, forgot the patch.
Comment #2
sunFinally had time to review this patch. I've cleaned-up some minor parts and reworded some strings. Should still work, however, needs testing.
Also, thanks for fixing that stuff we missed in the port to 6.x. :)
Comment #3
sunHeh... I accidentally committed the administration form in switchtheme.admin.inc already, so I've also committed the rest of this patch now.
Comment #4
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #5
panji commentedThanks Sun,...
Great Patch,.. it's work,.. nice,... so I can configure for mobile browser, and other browser independently,...
But now,.. can we make some little improvement by detecting java and flash plugin? when the browser doesn't have java installed or flash installed, we can make auto switch for the themes..
Regards,..
Because it's look like the same,.. is it ok to reopen the issue? and add " (+ js, and flash)" on the title?
Comment #6
panji commentedcreating on new issue for it...
Comment #7
sunIt's unlikely that a JS-based detection will be added to SwitchTheme. Anyway, please open a new issue for this, since this issue performs a server-side detection.
Comment #8
panji commentedThanks,.. sure,..
I'll make a new issue for it..
Comment #9
jameselkins commentedHi,
I'm working on a D5 site so I needed this functionality. Here's my patch, so far it will bring up the settings page and insert the values into the variable table but will give a response like:
Warning: Table 'watchdog' was not locked with LOCK TABLES query: INSERT INTO watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (1, 'php', 'Duplicate entry 'switchtheme_browser_7b74ce3f59567e65d9dc5c2c8743' for key 1\nquery: INSERT INTO variable (name, value) VALUES ('switchtheme_browser_7b74ce3f59567e65d9dc5c2c87432e8e', 's:7:\\"default\\";') in /Applications/MAMP/htdocs/drupal-5.12/includes/database.mysql.inc on line 174.', 2, '', 'http://localhost:8888/drupal-5.12/?q=admin/settings/switchtheme/browser', '', '::1', 1228321625) in /Applications/MAMP/htdocs/drupal-5.12/includes/database.mysql.inc on line 174
whenever I try to save the settings. Also, even though the name/values get put into the variable table, the browser detection code does not work - perhaps because it is in the _menu() hook and not the _init() hook? A good test browser is Safari vs. Firefox. The browser detection was in the _init() hook in the D6 version, but my understanding is that it's supposed to be done in the _menu($maycache) hook in D5. I've commented the code @ the places where I think it's having trouble - look @ lines 119 & 83. Thanks for the help.
Comment #10
jameselkins commentedSorry, last attachment wasn't a patch, thanks for the heads up sun.
Comment #11
sunSorry, this patch violates pretty much every coding standard mentioned in http://drupal.org/coding-standards
Comment #12
jameselkins commentedI ran the code through the coder module mentioned in the http://drupal.org/coding-standards site and eliminated all errors. Perhaps this will be better?
Comment #13
sun@jameselkins: Please click on the patch you attached and have a closer look at it - it contains wrong indentation all over the place, changes a bunch of lines which it does not needs to, aso.
Comment #14
robloachWheeeee!
Comment #15
sunComment #16
pyctures commentedI would like to provide a specific theme for iPhone on my Drupal 6 site.
I already installed Browscap.
Is your patch providing the behavior of switching from Default theme (set for PC) to Mobile theme (designed for iPhone) ?
How to install this patch ?
(I am a newbie in Drupal. I am able to install a module. I have never installed a patch).
Thanks for your help.
Comment #17
srinikasturi commentedThis patch works well. Thank you very much. Unfortunately, I've found that the search results (native Drupal as well as Apache Solr) and the profile page using APK pick up the theme marked as 'Default' in admin/build/theme, rather than the theme for that particular browser. Please can someone help?
Thanks!
Comment #18
sunThanks for the re-roll! If you don't mind, I'll do a in-depth review here:
Wrong indentation.
Duplicate case statement termination. return is sufficient.
We should not change translatable strings in existing versions.
Needless blank line.
Wrong indentation. I do not understand the comment after in there; it should go.
Clearly visible: Wrong indentation in closing braces.
Same here.
huh?
Comment #19
srinikasturi commentedFor #17, found a fix. Use the Module Weights module. http://drupal.org/project/moduleweight and set the switchtheme weight to -10 so that it runs before the search module and the other modules. That way, no matter what comes up, it will use the theme supplied by switchtheme.
Sun, there were some issues with the patch on here. It didn't work straight out of the box on our D5 install. We'll be uploading the fixed patch shortly. I am sure there will be coding convention issues, as its one of our first attempts at fixing Drupal code. Apologies in advance.
Comment #20
MJL-1 commentedIt would be great if the Switchtheme project team leader rolled into an Official 5.x-1.4 release of the Switchtheme module the updated code that enables Switchtheme to support the Browscap module so Drupal can switch themes based on a visitor's browser. (i.e., that incorporates the vetted changes from the final patch code).
NOTE: "Starting with Switchtheme 6.x-1.1, Switchtheme provides support for the Browscap module to switch themes based on the browser of a visitor." Reference: http://drupal.org/project/switchtheme
In light of the successful patch development for the 5.x dev branch, it appears that this functionality could be easily committed to an Official release, i.e., 5.x-1.4. If there is no time for a formal official release, it would be much appreciated if the final 5.x -1.3patched module code were posted here for clarification/convenience of the community.
Comment #21
sunYes, this has a chance to be incorporated into the next official release for 5.x. However, I need a patch that applies the (very) same changes to 5.x. Note that I need the code to be as equal and comparable as possible. So, to get this in, the patch from #2 should be used as base. Most of the code for this functionality should be literally the same in 5.x and 6.x.
Comment #22
MJL-1 commentedsrinikasturi, please post your patch for Switchtheme 5.x-1.3. Did you use sun's #2 as a baseline? Is the Module Weights module required to make this work in D5?
sun indicates that an Official 5.x - 1.4 release should be feasible (sometime soon hopefully). Your contribution to this endeavor will be appreciated.
Comment #23
MJL-1 commentedsun, this is very good to hear! Please let me know if I can help you further with this effort. Thanks
Comment #24
sunResetting version, category, and status to proper values.
Comment #25
srinikasturi commentedMy colleague Santhosh Kumar worked on this, and I can request him to detail what exactly needed to change in the patch to make it work. In the meantime, here's the module as it is working on our site today. Visit www.peppervillage.com on IE6, Firefox and mobile to see 3 different themes in action. This uses patch # 2. Hope this helps.
Comment #26
srinikasturi commentedWhat would be really cool is to have a set of themes available for each browser setting so that the original functionality of switchtheme - to be able to choose a different theme, is still available as a subset of themes enabled for the user's browser. Currently, if the browscap functionality is being used, the theme chooser doesn't work.
Comment #27
sunDrupal 5 is no longer supported with the release of Drupal 7.