3 replies [Last post]
dmetzcher's picture
Offline
Joined: 03/16/2010

I have a content type on which I do not want to display the right sidebar, even if there are blocks in the right sidebar that would ordinarily be displayed (due to block visibility settings) in the right sidebar.

I found this topic on Drupal.org: http://drupal.org/node/448172

This comment tells me what to do, and I understand it, but I'm having a little trouble creating the page-[contentType]-tpl.php file. I'm experimenting now, but I cannot seem to get it right. The first block that I'm displaying in the footer is appearing where the right sidebar would normally be, so I'm definitely doing something wrong. :(

What parts of the PHP code in the Litehouse page.tpl.php must be removed in order to get rid of the right sidebar?

Thanks!

dmetzcher's picture
Offline
Joined: 03/16/2010

I think I may have figured it out. Here's what I did, but I'd feel more comfortable with confirmation that this is the best way to remove the right sidebars (right, rightright, rightleft) in a custom page.tpl.php (mine is actually page-user.tpl.php because I don't want the right sidebar on the user profile pages).

If there's a more graceful way, please let me know. I think this is working, however.

First, I changed this (line 78)...
<body<?php print phptemplate_body_class($left, $right); ?>>
to...
<body<?php print phptemplate_body_class($left, ""); ?>>

Basically, I'm not sending the second argument for phptemplate_body_class.

Second, I removed the entire section of code that causes the right sidebars to be created (starts at line 162 and ends at line 188)...
<?php if ($right) { ?>
    <div class="sidebar-right clear-block">
          <?php print $right ?>
          
<!-- Extra Sidebar Regions -->
    
      <?php if ($rightright || $rightleft ) { ?>
            <div id="extra-right-regions" class="clear-block">
      <?php if ($rightleft) { ?>
        <div class="userblock <?php echo $rightBlocks; ?>">
          <div class="userblock-inner">
                    <?php print $rightleft ?>
          </div>
       </div>
             <?php }?>
             <?php if ($rightright) { ?>
       <div class="userblock <?php echo $rightBlocks; ?>">
         <div style="border-left: 1px dashed #aaaaaa;" class="userblock-inner">
                   <?php print $rightright ?>
             </div>
      </div>
            <?php }?>
          </div><!-- End of Extra Sidebar Regions -->
        <?php } ?>         
          
    </div>
      <?php } ?>

I hope all this is correct. I don't want to do it in an "ugly" way, especially if it will cause issues later. Since I'm only overriding one type of page (and not the whole site), I figured quick and dirty would work and then I'd wait to see what Rob D., or someone else, says.

Thanks!

Rob D.'s picture
Offline
Joined: 04/09/2008

There's no problem with doing it this way. Usually the way I do it is just to set what pages the blocks appear on in Administer > Site Building > Blocks, by configuring each block and choosing where I want or don't want it to appear in the Page specific visibility settings.

If I don't want anything in the right column on the user pages, for example, I select 'Show on every page except the listed pages' and add the path 'user/' to the text field.

I'm guessing you're familiar with this, so maybe there's a limitation with this method that I'm not thinking of - the only reason I do it is to prevent having a lot of different tpl files, but perhaps if you've got a lot of blocks to deal with it probably is just as easy to remove the call entirely as you've done.

dmetzcher's picture
Offline
Joined: 03/16/2010

I have some pages that come after the /user page, so, for example...

/user/3/organizations
If I set block visibility to not show on...
user/*
...the block can never be shown on...
/user/3/organizations

I experimented a little (http://drupal.org/node/804058) and it seems there's no way to create a tpl file that only applies to a user's Content Profile/Panels page, so I ended up using the Context module to selectively display blocks on pages where it would otherwise be impossible. Context can actually be used to replace the Blocks administration entirely, but I prefer to use it for the few cases where it's necessary as I find the interface more difficult to use than the standard blocks interface. Luckily, it completely ignores the visibility settings for a block and can display blocks where I've said (in the visibility setting for those blocks in the core Blocks administration) that they cannot be displayed. It works, but it's not as elegant as I had wanted.

What we really need is a module or (better yet) modification to Drupal Core where we can use the following format in the visibility settings...

user/*/organizations

...where the asterisk is a wildcard for anything that comes between the slashes. Right now, if you used that, everything after the asterisk is ignored and it would be the same as using...

user/*

Support hours: 9AM - 5PM EST, Mon - Fri

Follow us on: