I'm pretty sure the .no-sidebars class is being printed when there is indeed sidebars. I checked http://magazeen.fusiondrupalthemes.com/ and I see it there as well.

Please advise on how to fix this.

Hope that helps,

Thanks

Comments

jeremycaldwell’s picture

Assigned: Unassigned » sociotech
gmclelland’s picture

I noticed in includes/theme.inc the .no-sidebars class is defined if the $variables['layout'] == 'none'.

Maybe in template.php we can just set $variables['layout'] == 'none' if $vars['sidebar_first'] and $vars['sidebar_last'] = empty?

It also looks like .no-sidebars body class is always printed in Fusion themes.

What do you think?

stephthegeek’s picture

Status: Active » Closed (won't fix)

My understanding is that we can't fix this. These are the body classes used by core, except they're not accurate because we use RTL-friendly sidebar names rather than right/left. Fusion adds its own .layout-main, .layout-first-main-last, etc which are accurate.

gmclelland’s picture

Well, could fusion supply a fusion-no-sidebars body class?

stephthegeek’s picture

It does. That's .layout-main :)

gmclelland’s picture

Great. Easy enough

muhleder’s picture

Status: Closed (won't fix) » Needs work

Sorry for re-opening this, but it seems a bit of an unnecessary wtf in such a great theme.

Couldn't we just put something like

$vars['body_classes'] = str_replace('no-sidebars', '', $vars['body_classes']);

around the top of fusion_core_preprocess_page()?

Thanks,
Mark

digitalfrontiersmedia’s picture

I second this. no-sidebars has been pretty standard for a while. Why not try to translate this so it is more similar to what people have grown accustomed to coming out of Drupal Core? It would indeed make adoption a little less confusing. As it stands now, it's definitely odd for it to say no-sidebars when there are. And might invoke unintended CSS, which is probably misinterpreted by some as "bugs" in Fusion...

galactus’s picture

Fusion is a great theme, this issue is small, but can be so helpful for themeing.

pixelwhip’s picture

Version: 6.x-1.0-rc1 » 6.x-1.0
Status: Needs work » Needs review
StatusFileSize
new1.55 KB

I created a patch that preserves the core .no-sidebars, .one-sidebar, two-sidebars body classes.

This is my first patch, so any feedback on how it can be improved would be much appreciated.

jrabeemer’s picture

#10 works for me.

It's simple enough.

aosiname’s picture

#10 worked for me also for drupal 6.x site

i used zen once and if i had for example a url alias to alias all photo pages like so:

photos/photo-1
photos/photo-2
photos/photo-3

it would add a class "section-photos" to the body like on:
http://www.livelinknewmedia.com/digital-marketing/Customer%20Acquisition

I am sure i have seen fusion do this also using a class of "page-photos" on the body but it doesnt seem to happen anymore.

Any ideas?

check out http://luc.osinova.co.uk/image-galleries/christmas-2009
it adds "page-image" to the body - although it should technically be page-image-galleries

but it doesnt work on my other fusion sites

aosiname’s picture

following #10s example, i managed to get it working.

heres the code i added to fusions template.php

/*add a body class for arg(0)*/
$curr_path = drupal_get_path_alias($_GET['q']);
$curr_path_array = explode("/", $curr_path);
$curr_path_0 = $curr_path_array[0];
$body_classes[] = 'section-' . $curr_path_0;//strtolower(preg_replace('/[^a-zA-Z0-9-]+/', '-', drupal_get_path_alias($_GET['q']))); // add a class based on arg 0
/*END add a body class for arg(0)*/

toddota’s picture

Status: Needs review » Reviewed & tested by the community

#10 worked for me. Awesome! Thanks pixelwhip.

stephthegeek’s picture

Assigned: sociotech » aquariumtap
aquariumtap’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.63 KB

The attached patch is a slight variation on #10.

Intended behavior:

  • The .no-sidebars class will only show when no sidebars are present, fixing this issue
  • .one-sidebar when only one sidebar is in use
  • .two-sidebars when two sidebars are in use
aquariumtap’s picture

StatusFileSize
new1.59 KB

Please disregard above patch, I forgot to roll out the most recent version :) See this one instead.

Thank you pixelwhip for fixing this!

extensive’s picture

USE FOLLOWING CODE IN template.php.......and give ur sidebar classes

function phptemplate_body_class($sidebar_first, $sidebar_last) {
if ($sidebar_first != '' && $sidebar_last!= '') {
$class = 'sidebars';
}
else {
if ($sidebar_first != '') {
$class = 'sidebar_first';
}
if ($right != '') {
$class = 'sidebar_last';
}
}

if (isset($class)) {
print ' class="'. $class .'"';
}
}

---------
AND
------
print phptemplate_body_class($sidebar_first, $right);

GIVE THAT CODE FOR BODY TAG IN page.tpl.php

aquariumtap’s picture

Assigned: aquariumtap » Unassigned

Status: Needs review » Needs work

The last submitted patch, 824988-no-sidebars-class-fix-D6.patch, failed testing.

hansrossel’s picture

The Zen theme has the same issue, this is how it is solved there:

  // We need to re-do the $layout and body classes because
  // template_preprocess_page() assumes sidebars are named 'left' and 'right'.
  $vars['layout'] = 'none';
  if (!empty($vars['sidebar_first'])) {
    $vars['layout'] = 'first';
  }
  if (!empty($vars['sidebar_second'])) {
    $vars['layout'] = ($vars['layout'] == 'first') ? 'both' : 'second';
  }
  // If the layout is 'none', then template_preprocess_page() will already have
  // set a 'no-sidebars' class since it won't find a 'left' or 'right' sidebar.
  if ($vars['layout'] != 'none') {
    // Remove the incorrect 'no-sidebars' class.
    if ($index = array_search('no-sidebars', $vars['classes_array'])) {
      unset($vars['classes_array'][$index]);
    }
    // Set the proper layout body classes.
    if ($vars['layout'] == 'both') {
      $vars['classes_array'][] = 'two-sidebars';
    }
    else {
      $vars['classes_array'][] = 'one-sidebar';
      $vars['classes_array'][] = 'sidebar-' . $vars['layout'];
    }
  }
toddwoof’s picture

Until another fix comes along, we added this to the subtheme's template.php to remove the "no-sidebars" class if there is content in either of the sidebars:

function YOURTHEMENAME_preprocess_page(&$variables) {
if($variables['sidebar_first'] != '' || $variables['sidebar_last'] != ''){
$variables['body_classes'] = str_replace('no-sidebars', '', $variables['body_classes']);
}
}

nabajit’s picture

Version: 6.x-1.0 » 7.x-2.x-dev

Changing the following in theme.info file resolved this issue for me_
regions[sidebar_first] = Left Sidebar
regions[sidebar_second] = Right Sidebar

I guess sidebar_first and sidebar_second is the default name of these regions to body classes work correctly.

Thanks.

limbovski’s picture

Fixed in Drupal 7 by changing:

regions[sidebar] = Sidebar

to

regions[sidebar_first] = Sidebar

in my themes .info file.

I assume Drupal bases it's decisions on the region names sidebar_first, sidebar_second...

Poieo’s picture

Issue summary: View changes
Status: Needs work » Closed (fixed)

This has been fixed in Fusion core for some time now.