Domain_theme module uses hook_custom_theme to change the default theme for certain domains.

When i visit that domain as an anonymous user, $sweaver->get_theme_key() returns the theme defined in hook_custom_theme.
If i try to change the theme as user one using sweaver, $sweaver->get_theme_key() returns the default theme provided.

This means i cannot use sweaver to style pages that have their theme changed using hook_custom_theme.

Is it posible to reset the sweaver instance on hook_custom_theme?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

svdhout’s picture

Title: Sweaver frontend form initiated before hook_custom_theme » Use menu_get_custom_theme in __construct

I figured it out.

The sweaver object constructor uses variable_get('theme_default', 'garland') to set_current_theme.
If a custom theme exists this should be used instead of the theme_default variable

private function __construct() {
    if ($theme_key = sweaver_session(NULL, 'sweaver_theme')) {
      $this->set_current_style($theme_key);
    }
    else {
      $this->set_current_style(variable_get('theme_default', 'garland'));
    }

    if (!$this->is_configured()) {
      $this->register_plugins_configuration();
    }
  }

should be

private function __construct() {
    if ($theme_key = sweaver_session(NULL, 'sweaver_theme')) {
      $this->set_current_style($theme_key);
    }
    else {
      if ($custom_theme = menu_get_custom_theme()) {
        $this->set_current_style($custom_theme);
      }
      else {
        $this->set_current_style(variable_get('theme_default', 'garland'));
      }
    }

    if (!$this->is_configured()) {
      $this->register_plugins_configuration();
    }
  }
jyve’s picture

Assigned: Unassigned » swentel
Rory’s picture

Version: 7.x-1.1 » 7.x-1.x-dev
Status: Active » Needs review
FileSize
537 bytes

Patch attached.