Hi, and thank you for your work. I appreciate it.

I don't understand using the same class names for body classes as that of region classes.

Perhaps I "don't get it", but I try to use classes over id, so if I am overriding something like
#sidebar-second .sidebar-second
I would have a tendency of using
.sidebar-second {width: 180px;} for example
and I have then spent a silly amount of time trying to figure out why the layout doesn't work. It doesn't occur to me that body has the same class. It is just not how I think about it.

Let me know if I have to join the real world.

Comments

aquariumtap’s picture

Status: Active » Closed (won't fix)

Hi js, these aren't added by Fusion. They're added by core.

In theme.ini:

/**
 * Preprocess variables for html.tpl.php
 *
 * @see system_elements()
 * @see html.tpl.php
 */
function template_preprocess_html(&$variables) {
  // Compile a list of classes that are going to be applied to the body element.
  // This allows advanced theming based on context (home page, node of certain type, etc.).
  // Add a class that tells us whether we're on the front page or not.
  $variables['classes_array'][] = $variables['is_front'] ? 'front' : 'not-front';
  // Add a class that tells us whether the page is viewed by an authenticated user or not.
  $variables['classes_array'][] = $variables['logged_in'] ? 'logged-in' : 'not-logged-in';

  // 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';
  }

Core looks for specific regions to try and identify sidebars, and adds classes to the body tag to assist with layout. I agree this can be confusing when trying to style the sidebar regions. It's possible for us to undo the classes added to the body tag by core, but we try not to go against the grain so themers who come with drupal-specific experience will do well by their assumptions.

Sorry for your troubles!

js’s picture

Thanks for taking the time to explain, and your code. I hope it helps others as well. I would normally try to use class pointers in my CSS, but for the sidebars I have just switched to using the id.

jmcintyre’s picture

If the classes are added in core, perhaps the sections of Fusion themes' starter CSS files that reference the classes should be amended? Example:

/* Sidebar Regions
-------------------------------------------------------------- */
/* Sidebar widths can be controlled through theme settings */
.sidebar-first {
}

.sidebar-second {
}

That seems to suggest that properties for sidebars should be added there... but that results in the properties applying to the body or its descendants. Perhaps these classes should be removed from the CSS, or IDs should be used instead as #2 mentioned. At least a note of explanation in the CSS comments could be helpful.