I couldn't find this issue covered in the forums. I am using Drupal 5.1. I have a modified version of Garland theme, with some new regions. All is working well except for one thing I can't figure out.

I added a region called 'fyi' with custom blocks assigned to it. This new region is displaying above (at the top of) the right sidebar. It works as long as there is a block assigned to right_sidebar. But if no block is assigned to right_sidebar in blocks admin then the region 'fyi' and its blocks doesn't display. I want the region 'fyi' to display with its assigned blocks on the right side of the page (in the sidebar) even if there is no block assigned to right_sidebar.

I tried modifying page.tpl, but it doesn't work. Any ideas on what am I doing wrong?

This works if there is a block assigned to right_sidebar:

...
<?php if ($sidebar_right): ?>
        <div id="sidebar-right" class="sidebar">
          <?php if (!$sidebar_left && $search_box): ?><div class="block block-theme"><?php print $search_box ?></div><?php endif; ?>
          <?php print $fyi; // ADDED?>
          <?php print $sidebar_right ?>
        </div>
      <?php endif; ?>
...

This is what I tried but it doesn't work as expected:

...
<?php if ($sidebar_right || $fyi):   // MODIFIED to include $fyi ?>
        <div id="sidebar-right" class="sidebar">
          <?php if (!$sidebar_left && $search_box): ?><div class="block block-theme"><?php print $search_box ?></div><?php endif; ?>
          <?php print $fyi; // ADDED?>
          <?php print $sidebar_right ?>
        </div>
      <?php endif; ?>
...

Comments

nevets’s picture

I wonder if this because $sidebar_right and $fyi are strings. You might try

<?php if ( strlen($sidebar_right . $fyi) > 0 ): 

or even

<?php if ( $sidebar_right . $fyi ): 

or if neither of those works, there is always

<?php
$show_right_sidebar = false;
if (  $sidebar_right ) {
  $show_right_sidebar = true;
}
if (  $fyi ) {
  $show_right_sidebar = true;
}
?>

<?php if ($show_right_sidebar):
macunni’s picture

Thanks Nevets, but none of these worked. I do appreciate you taking the time to help just the same. If you happen to think of something else to try or look at, I'm open. Thanks....

Mark

nancydru’s picture

A real low-tech approach would be to create an untitled block with nothing but <br> in it and place it in the right side bar on the same pages you want the FYI to appear on.

Nancy W.
now running 5 sites on Drupal so far
Drupal Cookbook (for New Drupallers)
Adding Hidden Site Design Notes

macunni’s picture

Thanks Nancy. This worked and gives me the desired affect. However, I wish I could find a fix that didn't require generating bloated html. But, I'm happy it's working and is doing what I want. Thanks for the assistance.

Mark

macunni’s picture

I finally figured it out, so I figured I should share it just in case it helps someone else. The problem was, how to display a custom region in place of the right sidebar in the Garland theme. The custom region's name is 'fyi'.

First I modified the template like so;

...
function phptemplate_body_class($sidebar_left, $sidebar_right, $fyi) {
  // if ( ($sidebar_left != '' && $sidebar_right != '') ) { //*** REMOVED
  if ( ($sidebar_left != '' && $sidebar_right != '') || ($sidebar_left != '' && $fyi != '')  ) { //*** ADDED
    $class = 'sidebars';
  }
  else {
    if ($sidebar_left != '') {
      $class = 'sidebar-left';
    }
    if ($sidebar_right != '') {
      $class = 'sidebar-right';
    }
    if ($fyi != '') { //*** ADDED FROM HERE
      $class = 'sidebar-right';
    } //*** TO HERE
  }

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

Then I modified page.tpl like so;

...
<body<?php print phptemplate_body_class($sidebar_left, $sidebar_right, $fyi); ?>> <!-- MODIFIED -->
...
<?php if ($sidebar_right || $fyi): ?> //*** MODIFIED
        <div id="sidebar-right" class="sidebar">
          <?php if (!$sidebar_left && $search_box): ?><div class="block block-theme"><?php print $search_box?></div>
          <?php endif; ?>
          <?php print $fyi ?> //*** ADDED
          <?php print $sidebar_right ?>
        </div>
       <?php endif; ?>
...

Now my region displays in the right sidebar, just like the normal sidebar if it's not being used or it displays both, with fyi on top, just like I wanted.

Mark