When the user doesn't use the default theme defined for a web site, the module uses the wrong CSS file.
In my case, the default theme is Garland, but the user's theme is Zen Classic. The CSS file used by the module is garland.css, while it should be zen_classic.css (which I created); if the file name doesn't match with the file name the module expects, then it should use activemenu.css.

Comments

avpaderno’s picture

I checked the values of the global variables $theme, $theme_key, $custom_theme; the first two variables seem to be set to an empty string, and the last one is set to zero.

That is strange, as Drupal is showing the correct theme.

avpaderno’s picture

It seems that if the user has set a theme for himself, those variables get a not usable value; in this case, the theme used is the one reported by $user->theme, where $user is the global variable associated with the current user object.

avpaderno’s picture

I got it to work by changing the function activemenu_theme_css() to be:

function activemenu_theme_css() {
  global $custom_theme, $theme, $user;
  
  if (isset($user->theme) && $user->theme != '') {
    $current_theme = $user->theme;
  }
  elseif (!empty($custom_theme)) {
    $current_theme = $custom_theme;
  }
  else {
    $current_theme = $theme ? $theme : variable_get('theme_default', 'garland');
  }
  
  $path = drupal_get_path('module', 'activemenu');
  $file = $path .'/theme/'. $current_theme .'.css';
  if (file_exists($file)) {
    drupal_add_css($file);
  }
  else {
    drupal_add_css($path .'/activemenu.css', 'theme');
  }
}

I forgot to say I am using Drupal 6.3.

avpaderno’s picture

Now I got it to use the right CSS file if the user has set his own theme, and I also fixed a problem in the visualization of the navigation menu which had the plus (and minus) images placed over the menu titles. I am not able to make the Zen Classic use the plus, and minus images (the theme uses its own images for the menus).

avpaderno’s picture

Title: Uses the wrong CSS file » Wrong CSS file being used

The module is also using the wrong CSS file in pages like admin/build/block/list/<theme> (when <theme> is not the site theme).
The issue seems caused by $theme, $theme_key, $custom_theme not getting any useful value if init_theme() is not called before to check their values.
init_theme() cannot be called in pages like admin/build/block/list/<theme>, or it would force the page to be rendered using the site theme (which is not the wanted thing).

The problem is present also in Drupal 6.4.

avpaderno’s picture

As also reported by a comment in the jstools.module referred to the function jstools_theme_include():

To avoid having to prematurely initialize the theme, call this function from a hook_footer() implementation. hook_footer() typically is called after the theme has been initiated, but before the header has been generated.

Inside the implementation of hook_footer() the variables $theme, $theme_key, $custom_theme get a useful value.

avpaderno’s picture

Did anybody else notice that in some themes the [+], and [-] are placed to the left of the imagine used by the theme for the <li> tags?

nedjo’s picture

Status: Active » Fixed

Applied, thanks.

Status: Fixed » Closed (fixed)

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