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