What about using a preprocess function in a module to unset the sidebar
region variable if the condition is met?
Steve
Khalid Baheyeldin wrote:
On Fri, Jul 17, 2009 at 2:01 PM, Earnie Boyd
<[email protected] <mailto:[email protected]>>
wrote:
Quoting "Tomá? Fülöpp (vacilando.org <http://vacilando.org>)"
<[email protected] <mailto:[email protected]>>:
Hi,
I cannot find a generic way how to disable a sidebar
programmatically.
In my module, if some conditions are met, I would like to make
sure that the
whole sidebar (or any blocks in it) are not rendered at all,
regardless of
the theme.
Could somebody advise, please? Sorry if it's obvious..
I think you want to use hook_block()[1].
[1] http://api.drupal.org/api/function/hook_block
He is talking about the whole sidebar, hence a region, not a block.
hook_block() will not help here.
In the past we have done it by setting the visibility PHP code for
each block
in a given region, and that would make the entire sidebar invisible if
the
conditions are met. It is a pain if you have more than a few blocks in
that
region (right side bar for example).
You said you don't want it in the theme, but it would be a simple
change in
page.tpl.php
<?php if ($right): ?>
<?php if (*!custom_visibility_function*()) ?>
<div id="sidebar-right" class="sidebar">
<?php print $right ?>
</div>
<?php endif; ?>
<?php endif; ?>
The other option is to use preprocess_block(). Perhaps something like
this in
template.php
<?php
function phptemplate_preprocess_block(&$variables) {
if ($variables['block']->region = 'right') {
if (!custom_visibility_function()) {
unset($variables['block'];
}
}
}
?>
Still in the theme though.
--
Earnie
-- http://r-feed.com/ -- http://for-my-kids.com/
-- http://www.4offer.biz/ -- http://give-me-an-offer.com/
--
Khalid M. Baheyeldin
2bits.com <http://2bits.com>, Inc.
http://2bits.com
Drupal optimization, development, customization and consulting.
Simplicity is prerequisite for reliability. -- Edsger W.Dijkstra
Simplicity is the ultimate sophistication. -- Leonardo da Vinci