In template_preprocess_html() we are adding sidebar CSS classes:

 // Add information about the number of sidebars.
  if (!empty($variables['page']['sidebar_first']) && !empty($variables['page']['sidebar_second'])) {
    $variables['classes_array'][] = 'two-sidebars';
  }
  elseif (!empty($variables['page']['sidebar_first'])) {
    $variables['classes_array'][] = 'one-sidebar sidebar-first';
  }
  elseif (!empty($variables['page']['sidebar_second'])) {
    $variables['classes_array'][] = 'one-sidebar sidebar-second';
  }
  else {
    $variables['classes_array'][] = 'no-sidebars';
  }

Those CSS classes are based on the assumption that the current theme uses those two regions (sidebar_first and sidebar_second) which is not always the case. The core preprocessor (template_preprocess_HOOK) should NOT make such assumptions. It is really annoying to get rid of those CSS classes with array_search() if your theme does not use regions with that name. Furthermore it might be so that your theme uses different keys for the sidebars in the THEME.info (e.g. regions[sidebar_one] = First Sidebar ... etc.). In this case the user would get a "no-sidebars" class on the "body" tag which is really annoying considering that he actually does have sidebars (they are just named differently). I would suggest moving those to the theme's preprocessors instead (e.g. bartik_preprocess_html).

What are your thoughts on this?

Comments

dvessel’s picture

I agree. Either remove it and leave it up to each theme to add the classes or it should simply add a class name based on the set regions for the theme. Not just the sidebars.

betarobot’s picture

Actually no-sidebars class is helpful enough in many cases. But totally agree, the logic should be different.

Roughly something like: !sidebar_* = no-sidebars, otherwise sidebar_this and sidebar_that (picked up from theme.info).

Not sure though how would it look in PHP if possible at all.

joelpittet’s picture

Status: Active » Closed (duplicate)

Doing some triage. This was fixed a while back, also we build up most classes in templates now, and try to do it in classy only.

template_preprocess_html doesn't add any classes now.