I want to add an additional sidebar to my zen based theme with fixed columns.
I added it to the theme info, and printed it in the page.tpl.php file, but I don't know how to configure its CSS files to make it look correct; I don't know how to make the content region expand to fill the available space when there is an empty region with no blocks in it like with Zen.

My theme contains 4 columns:

  • left sidebar 1 (130 pixels)
  • left sidebar 2 (255 pixels)
  • content (509 pixels)
  • right sidebar (130 pixels)

The total width would be 1024 pixels.

How can I do that?

  • Are you asking what the css should be or where to put it? ...or something else? May 18 '11 at 0:28
  • i'm asking how the css should be ? and i want the css to hide the regions when there is no content in them May 18 '11 at 10:32
  • Have you tried context or panels?
    – chrisjlee
    May 25 '11 at 17:26
  • This question doesn't really have anything to do with Drupal. This is a CSS question, not a Drupal question. Check the faq for questions appropriate for this site.
    – Chaulky
    Jun 10 '11 at 22:50

You can do it with preprocess function at template.php template. I will write you just one example, and you can adapt it for your needs.

1.At Your template.php template.

function yourthemename_preprocess_page(&$vars, $hook) {
  $page = $vars['page'];
// if only left sidebar is present
  if ($page['left_sidebar'] && !$page['left_sidebar2'] && !$page['right_sidebar']) {
    $vars['class_content'] = t('yourclassforcontentwithsidebar');
    $vars['class_left_sidebar'] = t('yourclassforleftsidebar');
// if no sidebar is present
  if (!$page['sidebar_left'] && !$page['left_sidebar2'] && !$page['right_sidebar']) {
    $vars['class_content'] = t('yourclassforfullwidhtcontent');

You can find more variations here: php logical operators.

2.At your page.tpl.php, at all regions where you want flexible width, put extra class, for example for left sidebar:

   <?php if ($page['left_sidebar']): ?>
      <div id="left_sidebar" class="sidebar <?php print ($class_left_sidebar);?>" >
        <?php print render($page['left_sidebar']); ?>
    <?php endif; ?>
  • thank you but i solved this question using the preprocess function after i post it here but i forgot about this question Jun 21 '11 at 15:48

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .