Switching themes using the drop down works for logged in users, but not for others.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sun’s picture

Version: 6.x-1.x-dev » 5.x-1.x-dev
Assigned: Unassigned » sun
Status: Active » Needs review
FileSize
2.99 KB

Attached patch should fix this issue for 5.x.
6.x can come later.

wd’s picture

I've made some patch for Drupal-6.x.
The patch is:-

--- 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
+}
marcoBauli’s picture

Status: Needs review » Reviewed & tested by the community

the patch applies and fixes the problem on 5.x thanks!

dr00b’s picture

Worked for me as well (as soon as I figured out how to apply a patch).

Wolfflow’s picture

Priority: Critical » Normal
Status: Needs review » Reviewed & tested by the community

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?

Wolfflow’s picture

I have to change status from normal to critical. Tested on http://www.adaccs.at/drupal/

Billy Chimpson’s picture

Priority: Normal » Critical
Status: Reviewed & tested by the community » Needs review

thx a lot, you fixed my Drupal 6 Problem !

greetz
David

Wolfflow’s picture

Title: themes don't switch for anonymous users » themes don't switched for anonymous users
Version: 6.x-1.x-dev » 5.x-1.x-dev

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

Coupon Code Swap’s picture

Title: themes don't switched for anonymous users » themes don't switch for anonymous users
Version: 5.x-1.x-dev » 6.x-1.x-dev

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?

Wolfflow’s picture

Title: themes don't switched for anonymous users » themes don't switch for anonymous users
Version: 5.x-1.x-dev » 6.x-1.x-dev
Priority: Normal » Critical
Status: Reviewed & tested by the community » Needs review

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

Coupon Code Swap’s picture

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.

sun’s picture

Title: themes don't switch for anonymous users » Themes don't switch for anonymous users
Version: 6.x-1.x-dev » 5.x-1.1
FileSize
3.56 KB

New patch against DRUPAL-5. Please test, so I can re-roll it for D6 afterwards.

Coupon Code Swap’s picture

Let me know when you've got the Drupal 6 patch ready. I'll give it a thorough testing :)

sun’s picture

Since SwitchTheme's userbase is small, I've created a patch for D6. However, it's just the code, I haven't tested it.

sun’s picture

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

Coupon Code Swap’s picture

Alright! Switching themes by URL is working. I'll do some more testing tomorrow.

Wolfflow’s picture

Subscribe

sun’s picture

I still need at least one more qualified review to commit this. Thanks.

SeanA’s picture

Version: 5.x-1.1 » 5.x-1.x-dev

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.

Coupon Code Swap’s picture

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.

sun’s picture

Status: Needs review » Fixed

Thanks all, committed.

stephthegeek’s picture

Status: Fixed » Active

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?

sun’s picture

Status: Active » Fixed

@stephthegeek: Must be related to your multi-site setup. Please open a new issue. This one has been fixed.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

skoledin’s picture

FileSize
447 bytes

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.

noureddine’s picture

hey #skoledin i tried it, but it didn't work its not even switching my themes. any suggestion or any other updated fix for the anonymous user theme switching

thank you very much