Download & Extend

Administration Theme not working when theme selected for virtual site

Project:Virtual Sites
Version:6.x-1.3
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

Using Drupal 6.9, Virtual Sites 1.3

I created a custom, Zen-derived theme. I have 3 virtual sites set up, switching based on the Drupal/Sites/sitex.mysite.local condition. The switching is working properly.

I am able to specify different themes for each site and that functionality is working correctly. What is not working is the Administration Theme as set at http://sitex.mysite.local/admin/settings/admin. I'm just trying to keep Garland for my admin entry point and it seems to get overridden by my site-specific theme.

I can set up an Administrative "virtual site" so that I can keep Garland as the theme, but I would love to get any input you might have on where the theme gets overridden in the Virtual Sites module and how we can tweak it so that it allows the Administration Theme setting to be applied correctly.

Thanks much!

Craig

Comments

#1

Status:active» needs review

Set up a workaround.

  1. Installed Administration Theme module (http://drupal.org/project/admin_theme).
  2. Added the following function to my custom module:
    function _needs_admin_theme() {
      $admin_theme_disallow = FALSE;
      $admin_theme = FALSE;
     
      // check if some paths are disallow to get the theme
      if (trim(variable_get('admin_theme_path_disallow', '')) != '') {
        // pages that are defined by their normal path
        $admin_theme_disallow = drupal_match_path($_GET['q'], variable_get('admin_theme_path_disallow', ''));
       
        // pages that are defined with their alias
        $alias = drupal_get_path_alias($_GET['q']);
        if ($alias != $_GET['q']) {
          $admin_theme_disallow = $admin_theme || drupal_match_path($alias, variable_get('admin_theme_path_disallow', ''));
        }
      }
     
      // we should not show the admin theme if the user has no access or the path is in the disallow list
      if (!user_access('access admin theme') || $admin_theme_disallow) {
        global $custom_theme;
        $custom_theme = '0';
        return;
      }
     
      $admin_theme = (arg(0) == 'admin' || (variable_get('node_admin_theme', '0') && arg(0) == 'node' && (arg(1) == 'add' || arg(2) == 'edit')));
      // check if an option is enabled and if it results to TRUE
      $list = admin_theme_list();
      foreach ($list as $info) {
        $var = admin_theme_variable_name($info['module'], $info['option']);
        if ((bool)variable_get($var, '0') && module_invoke($info['module'], 'admin_theme', 'check', $info['option'])) {
          $admin_theme = TRUE;
        }
      }
     
      // some custom defined pages should get admin theme
      if (trim(variable_get('admin_theme_path', '')) != '') {
        // pages that are defined by their normal path
        $admin_theme = $admin_theme || drupal_match_path($_GET['q'], variable_get('admin_theme_path', ''));
       
        // pages that are defined with their alias
        $alias = drupal_get_path_alias($_GET['q']);
        if ($alias != $_GET['q']) {
          $admin_theme = $admin_theme || drupal_match_path($alias, variable_get('admin_theme_path', ''));
        }
      }
     
      // Use the admin theme for the current request (if global admin theme setting is checked).
      return $admin_theme;
    }
    This code was adapted from the admin_theme.module and the system_init() hook in system.module
  3. Replaced virtual_site_theme.module line 115 with the following:
    if (($context['theme']) && (!_needs_admin_theme())) {

I know this is a bit of a hack, but it accomplishes what I need for the time being.

#2

My solution is:
1) Go to admin/build/sites
2) Don't use 'Theme' feature (set to 'skip this feature') for every virtual site
3) Use 'Variable' feature for every virtual site:
theme_default=zen_subtheme
admin_theme=garland

(zen_subtheme is the name of your default theme and garland is the name of your admin theme)

I've also change weight of module 'Virtual Sites' to -1 in {system} table.

#3

When changing the weight, did you set only the main virtual sites module weight to -1, or did you also set all its associated submodules.

I'm noticing an issue with languages. If i set a virtual site to french, it starts in french as expected, but the user cannot override the language using the standard language selection block.

#4

Yes. I've changed weight only in main virtual sites module. I have an issue with page admin/build/block since themes doesn't switch properly. I've defined additional conditions because it is important that virtual sites shouldn't be changed on admin/build/block and admin/build/themes. Even so I still have problem on admin/build/block. Every time I've noticed problem I must go to admin/build/themes and submit themes. After that, build block page works properly. Strange.

#5

nobody click here