disable side-bar for some pages

Events happening in the community are now at Drupal community events on www.drupal.org.
newz2000's picture

Hi, I've got a few pages that need some extra width... is there a trick you'd suggest so that when I'm editing a page I can easily disable one of the sidebars?

Comments

Show on every page except the listed pages

Michael Hofmockel's picture

edit the sidebar you want to remove - /admin/build/block/list
under "Show block on specific pages:" select "Show on every page except the listed pages."
Under "pages" add the path you want to exclude. You could enter node/10/edit. Or you could use a wildcard to not show it on any node edit page. node/*/edit.

You could even write some special PHP and drop it in to make your own conditional show if you wanted.

Regards,
Michael Hofmockel
iMed Studios

Open Source || Open Access || Open Mind

Regards,
Michael Hofmockel

Open Source || Open Access || Open Mind

won't work

newz2000's picture

What I mean is that I'm editing a page and normally there'd be a side-bar but I decide that I don't want a side-bar there when people come to view it. There maybe 6 blocks in that sidebar, I don't want to go to all 6 blocks and tell them to add an exception for this one page.

For example, if I edit products/landscape/screenshots and the page looks cluttered because of the sidebar, I'm wondering if there's a way I can put a checkmark in a box on this page's edit form that effectively hides the sidebar for just this page, despite what the rules normally say for the individual blocks.

--
Matthew Nuzum
newz2000 on freenode

--
Matthew Nuzum
newz2000 on freenode

Use a different page

dldege's picture

Use a different page template for these pages that don't include the sidebar region div or do a

<?php
print $sidebar
?>
or add conditional logic in your current page.tpl.php or template.php to set the sidebar variable to null for the given pages.

For D5 in template php you can look at _phptemplate_variables and then "hook" of page. Then check your path or whatever and set $vars['sidebar-right'] = NULL;

OR

you can make a page-products-landscape-screenshots.tpl.php that doesn't have any support for the given region (double check the naming convention for the page template look ups - I always have to try a couple times to get it right).

Dan DeGeest
Lead Software Developer
iMed Studios
http://www.imedstudios.com/labs

Dan DeGeest
Software Developer
Somewhere or Another

How about a UI?

newz2000's picture

Good idea. I'm trying to think of ways to make a UI for this that would appear on the edit page. The two things that come to mind are to use a taxonomy or to add a custom field.

Any suggestions on which is best (or if there's another way)?

--
Matthew Nuzum
newz2000 on freenode

--
Matthew Nuzum
newz2000 on freenode

Hum, that's a trickier issue

dldege's picture

Hum, that's a trickier issue because you're adding per node flag (show sidebar or not) but that would not be readily available in the page theming to make the template decision since page has no idea what is in $content. So, it looks like you might have to rely in a URL path check or this just hit me

1) add the cck or custom checkbox value to the node type(s) in question.
2) in _phptemplate_variables you could add a static variable

<?php
function _phptemplate_variables($hook, $vars) {
  static
$sidebar = TRUE
 
if ($hook == 'node') //check the node for the above value and set static variable to FALSE if necessary


 
if (hook == 'page') {
     if (!
$sidebar) $vars['sidebar-whatever'] = NULL;
  }
}
?>

something like that should work.

Dan DeGeest
Lead Software Developer
iMed Studios
http://www.imedstudios.com/labs

Dan DeGeest
Software Developer
Somewhere or Another

Shucks! No way to do it from the UI?

matthewcornell's picture

Hi All. I have the same question - how to disable my right sidebar without editing each block's visibility settings - and I appreciate your answers. I'm a bit shocked that this apparently can't be done by mere mortals like me (I don't write HTML or CSS). Is there another way to do this?

Thanks,

matt

--
Matthew Cornell | matt@matthewcornell.org | 413-626-3621 | 34 Dickinson Street, Amherst MA 01002 | matthewcornell.org

I've instructed my editors to

newz2000's picture

I've instructed my editors to use some CSS in their post to accomplish this. For example, http://www.ubuntu.com/cloud you can see the left sidebar is missing. A css rule like this works:

sidebar-left { display: none; }

I think it would be cool to have a flag set for pages that don't need a sidebar. I don't know how to do this but I will investigate it when I do a redesign after the new year.

--
Matthew Nuzum
newz2000 on freenode

Invalid XHTLM

hd's picture

Nice non-intrusive trick. Works well. Unfortunately it is creating invalid XHTML because it puts a "style" element in the "body" section instead of inside "head".

This is a very good post

ss54's picture

@Michael Hofmockel
Thank you so much. Although I used this way a year ago, but I was rather confused on how to use it with wild card which your post has explained. I would be much more thankful if you would kindly guide me where to read on conditional PHP.

retracked

Michael Hofmockel's picture

retracked

Regards,
Michael Hofmockel

Open Source || Open Access || Open Mind

doubt

dhilip23's picture

Hi to all....

am new to drupal, i have hide my left didebar in my page.. but my right side bar display under the content of the page..

please any one help me..

Thanks

Don't know if this is already

wila's picture

Don't know if this is already solved for you guys, but the context module works wonders for me ;-)

Wila Wonder-ful

jojojibba's picture

I tried context. Super easy.
Thanks @wila

i´m not sure about the

CanOne's picture

i´m not sure about the variables function (from http://groups.drupal.org/node/20836#comment-72151) , cause i havent tested it yet

but to hide the sidebar with css or some conditions in the page.tpl or even with an extra page-type.tpl isnt the best solution because drupal is rendering all the blocks before rendering this stuff so at least you loose page speed

pretty easy way to find this out is to check the body classes in source after hiding a region with css
and i think thats the reason of dhilip23´s problem because its still loading the two-sidebars class

i´m tryin to find a better solution, like above with cck fields or something but to controll block rendering

havent tried context yet but i think i have to =)

context or Panels

shoebee2's picture

Use context.
great intro here: http://mustardseedmedia.com/podcast/episode38

Central Iowa Drupal Users Group

Group categories

Category

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: