when trying to administer blocks the theme does not switch to the administered theme.
| Project: | Role Theme Switcher |
| Version: | 5.x-2.0 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | tiutiun |
| Status: | closed |
- Install role theme switcher and enable it.
- set a different theme for the "authenticated user"
- now the authenticated user including admin will have the different theme assigned to them.
- go to admin/build/blocks
- select a different theme from the default theme
- theme stays at the same default theme.
expected behavior is that the theme displayed switches to the newly selected theme
quick fix is to disable theme switching when on the admin/build/blocks page - however I am surprised that this kicks in for the "admin/" path given that your documentations say it shouldn't - but nothing in your code actually checks to see if the path is admin/.. I think you may be relying on an assumption that your module is initialized after all the other modules - which may not be the case all the time.
so I suggest putting something like this in your init function..
if( arg(0) == 'admin' ) {
return;
}
OR
if (arg(0) == 'admin' && $user->uid == 1) {
return;
}or create a user permission which if enabled for a user - the theme switcher will not kick in.

#1
couple of other things - is there a reason why you are invoking the "system_themes()" function? I do not see the results of that being used anywhere. It is a heavy function and shouldn't be called unnecessarily.
I think I am seeing a race condition with that call
- try logging in as admin in two different browsers.
- quickly reload a couple of pages on both browsers.
- 1 out of 4 times you will find a list of warnings on the screen and your themes will start behaving unpredictably. The reason is that system_themes() deletes and recreates theme information in the system table - when there are two of the same user doing this the items can stay permanently deleted due to race conditions between the two.. I need to go back into admin/themes and reset my selected themes.
any chance you will move the code to use the drupal form api?
thanks,
#2
Hi, Panis.
Thank you for your notes :-)
I'll do my best to follow your advices and to release a new version ASAP
#3
Hello, Panis.
Here is a new release with all your notes implemented: 5.x-1.2 (http://drupal.org/node/199664)
Could you please check it once again?
Thank you
#4
Automatically closed -- issue fixed for two weeks with no activity.
#5
this is still busted in 2.0 version
#6
this patch fixes the admin/build/blocks page
#7
Conform to Drupal way it is a normal behaviour.
If you go to admin/build/blocks and try to switch between different enabled themes settings, you will see that interface theme also changes.
The reason is: when you switch to for ex "chameleon settings" - you see where regions are situated in this exactly theme, and you see where content of blocks will be situated.
Did my muddled explanations bring some light? :-)
#8
I cant see hear that the status of this post says "wont fix". Even though i have tried it myself, the role switcher switched things from bad to worse. My question is, what could actually cause a drupal website to switch from admin theme to the custom theme when administering admin/build/block. I dont know what the problem is and I need help. I have been on this for the past two weeks now. Please can someone help.
#9
Firstly, enabling the role switcher switched things from bad to worse. But I modified the init function like this;
function role_theme_switcher_init()
{
global $user, $custom_theme;
if( arg(0) == 'admin' && $user->uid == 1) return;
foreach ($user->roles as $key => $value)
{
$role_name = str_replace(' ', '_', $value);
$role_theme = variable_get(strtolower($role_name).'_theme', '');
// Change active theme in user object
$user->theme = $role_theme;
// Also change the active theme globally
$custom_theme = $role_theme;
drupal_clear_css_cache();
}
}
but still my admin/build/block still reverts to my custom theme(default theme). Still need help. Why is only my Block admin page reverting.
#10
For Drupal it is a NATIVE way to handle admin/build/blocks page.
The reason is:
We can have multiple themes and DIFFERENT names for regions. Assigning blocks to regions we need to see where to we assign blocks. Thus we need to have possibility to switch between themes in this interface.
That is why Role Theme Switcher does not handle this interface - it is handled by Drupal core.
By default in admin/build/blocks is shown theme, that is set as "Default Theme" in sites/build/themes.
In the Blocks interface you should select a theme, where you want to enable the blocks, and do your settings there.
This is quite logic behavior because you may use several themes on site - so you have to do block settings in each theme you use.
Please pay attention - on this page there is interface to switch themes. Check attached image.
#11
Thanks tiutiun. I fully understand your point. The Block interface makes use of your default theme. Fine, but as it stands how do I move forward? Since my default theme is what the Block interface is using, how do I administer the Block. I can't see the Block interface since its using my default theme(custom theme). Is there any way I can use a temporary theme to administer the Block, just so that I can change the theme.
Also, from the screenshot, I could not find the extend theme link. Is it a module that i will need to download. Pls clarify.
Will really appreciate your help. This is my second week on this. Thanks.
#12
Hello, drecute
I would try to guess without looking into the code of your theme - you do not show some variables, that responds for showing Administer Block interface (and a lot of other useful stuff).
Please insert the following code in the same piece of HTML, where you do show $content
-----------
<?php
if ($user->uid == 1)
{
echo('<ul>'.$tabs.'</ul>');
echo('<ul>'.$tabs2.'</ul>');
if ($messages)
echo($messages);
}
?>
------------------------------
It means: If user is admin - show Administer Block interface
It would be also good to insert the following piece of code in [HEAD] [/HEAD]
------------------
<?phpif ($user->uid == 1) { echo($styles); }
?>
------------------
It makes Administer Block interface nicer.
Please feel free to contact me via Skype: serj.tiutiun
So we can fix this issue a little bit faster
As for "Extend Theme" link - it is just a theme I have built for my site. In your case you should see here your theme.
#13
#14
No! you can change the status to fixed. I got it working after reinstalling drupal. I think something went wrong with the database. I live and grooving now with drupal. All is smooth. Thanks for the help.
One thing to add also is that <?= $content ?> does not work on my installation. so i changed it to
<?phpprint $content
?>