Themes don't switch for anonymous users
kulfi - October 21, 2007 - 06:54
| Project: | Switchtheme |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | sun |
| Status: | closed |
Description
Switching themes using the drop down works for logged in users, but not for others.

#1
Attached patch should fix this issue for 5.x.
6.x can come later.
#2
I've made some patch for Drupal-6.x.
The patch is:-
<?php
--- switchtheme.module 2007-08-31 21:56:14.000000000 +0700
+++ switchtheme/switchtheme.module 2007-12-09 19:46:14.000000000 +0700
@@ -148,11 +148,17 @@ function switchtheme_switch_form_submit(
// save the setting in the db for logged in users
// save the setting in the session for all others
if ($user->uid > 0) {
- variable_set('theme_default', $form_values['custom_theme']);
+ // FIX DEFAULT THEME CHANGED
+ //variable_set('theme_default', $form_values['custom_theme']);
if (user_save($user, array('theme' => $form_state['values']['custom_theme']))) {
$user->theme = $form_state['values']['custom_theme'];
}
}
+ // FIX ANONYMOUS SWITCH THEME
+ elseif (user_access('switch theme')) {
+ // save the setting in the variable for all others
+ $_SESSION['custom_theme'] = $form_state['values']['custom_theme'];
+ }
}
@@ -184,4 +190,4 @@ function switchtheme_select() {
}
asort($select);
return $select;
-}
No newline at end of file
+}
?>
#3
the patch applies and fixes the problem on 5.x thanks!
#4
Worked for me as well (as soon as I figured out how to apply a patch).
#5
Hi, have applied your patch (#2) to switchtheme on following demo Site:
Drupal Themes Showcase
it works ;-) : Site use Drupal 6.1 and all recommended D6 Themes.
But I need to click twice on the page , that means that i have to change for example
clicking primary_menus: from --> home --> to --> Gallery
to see the Theme change.
Is this normal?
anyway it does what i need for this Themes Demo Site!
Thanks!
Some days later!! I spoke victory to early:
I just went through many Browser Test and find out that there is still a bug.
It seems that the module using it for anonymous user get in conflict with "cookies" and cache settings of the browser you use: Safari - Opera the most affected.
So if anyone have a suggestion?
#6
I have to change status from normal to critical. Tested on http://www.adaccs.at/drupal/
#7
thx a lot, you fixed my Drupal 6 Problem !
greetz
David
#8
Hi crashovermind,
It would be nice to have some details on your solved issue. I'm working on a Theme Demo Site for the Community
address : http://www.adaccs.at/drupal/
and will collect infos about each Theme for D6.x(recommended). You aopinion is Welcome! Thanks
P.S.Link corrected
#9
The patch for Drupal-6.x does work with the dropdown. However, changing themes via URL still does not work. When adding &theme= to the URL, themes do not change in the same way they did with Drupal 4.7 and Drupal 5. As anybody gotten this working with URL?
#10
Hi All, just wnat to precise that on my comments #5 #6 #8 above I have corrected the link. The original Site does not exist anymore but is still my intention to apply Switchtheme.module on the new site on:
http://adaccs.at/drupal/ , this site is based on Drupal 6.2 and is in costruction. Drupal Themes D4,D5, screenshots gallery have been completed, D6 Themes Screenshots will soon follow. My intention is to build a voting sistem that define the best and most used and spread Themes wich will be applyed on the Site, therefore the module will be neded.
Any help are very much appreciate, I'm some how confident with Drupal but there is a lot of lack of knowledge with PHP.
Thank you for your attention
Cheers
#11
You can also preview Drupal themes here:
http://themebot.com/website-templates/drupal-themes
All of the new Drupal 6 themes will be added once the URL function for Switchtheme is fixed.
#12
New patch against DRUPAL-5. Please test, so I can re-roll it for D6 afterwards.
#13
Let me know when you've got the Drupal 6 patch ready. I'll give it a thorough testing :)
#14
Since SwitchTheme's userbase is small, I've created a patch for D6. However, it's just the code, I haven't tested it.
#15
#247348: Switchtheme switches the default theme not the users' has not only been marked as duplicate, but also confirms that this patch (for D5) works. Another test would be great, though.
#16
Alright! Switching themes by URL is working. I'll do some more testing tomorrow.
#17
Subscribe
#18
I still need at least one more qualified review to commit this. Thanks.
#19
Changing affected version, this problem does not occur on 5.x-1.1. The patch in #12 does seem to fix the problem for 5.x-1.x-dev.
#20
Hi sun. I've tested the Drupal 6 patch pretty thoroughly and everything seems to be working. Works for both anonymous and authenticated users. The switchtheme block is working. And, URL method works. There are a few Drupal 6 themes which do not work even though they are enabled in the Theme manager (do not appear in the drop down and can't be called via URL). I am thinking this is a problem with those specific themes, rather than switchtheme.
#21
Thanks all, committed.
#22
I seem to be having a related problem. Same problem is occurring with both 1.1 and dev, which is odd. I'm running a 4-site multisite setup with the same copy of the switchtheme module, and only ONE of my sites has the problem where anonymous users cannot switch the theme, either via the dropdown or by URL. I've triple checked permissions, upgraded, downgraded... any ideas for troubleshooting this further?
#23
@stephthegeek: Must be related to your multi-site setup. Please open a new issue. This one has been fixed.
#24
Automatically closed -- issue fixed for two weeks with no activity.
#26
As of switchtheme-6.x-1.1 it looks like this is still an issue for anonymous users. The following patch isn't a perfect solution, but it did what I wanted and provided enough permission granularity for my use. Just tacking it on here in case anyone else is still looking for a quick fix.