0

I'm trying to add class to the content, however its not adding anything

    function themename_preprocess_page(&$vars) {
      $is_sidebar_first_or_second= (empty($vars['page']['sidebar_first'])) || (empty($vars['page']['sidebar_second']));
      $is_sidebar_first_and_second= (empty($vars['page']['sidebar_first'])) && (empty($vars['page']['sidebar_second']));
      if ($is_sidebar_first_or_second) {
        $vars['page']['content']['#theme_wrappers'][0] .= ' one-sidebar';
      }

      if ($is_sidebar_first_and_second) {
        $vars['page']['content']['#region'] .= ' two-sidebar';
      }

    }

can anyone help me on this?

0
3

Have you tried this code ? I have taken it from here

// 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';
  }
2
  • yes i got it and worked for me very nice Dec 18 '12 at 15:56
  • but if i want to add some classes to the blocks related to their region Dec 18 '12 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.