<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<font size="-1"><font face="Arial">What about using a preprocess
function in a module to unset the sidebar region variable if the
condition is met?<br>
<br>
Steve<br>
</font></font><br>
Khalid Baheyeldin wrote:
<blockquote
cite="mid:4a9fdc630907171147i159bd40dyf429a9f3b522601d@mail.gmail.com"
type="cite"><br>
<br>
<div class="gmail_quote">On Fri, Jul 17, 2009 at 2:01 PM, Earnie Boyd
<span dir="ltr"><<a moz-do-not-send="true"
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 moz-do-not-send="true"
href="http://vacilando.org" target="_blank">vacilando.org</a>)" <<a
moz-do-not-send="true" 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 moz-do-not-send="true"
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 moz-do-not-send="true" href="http://r-feed.com/" target="_blank">http://r-feed.com/</a>
-- <a moz-do-not-send="true" href="http://for-my-kids.com/"
target="_blank">http://for-my-kids.com/</a><br>
-- <a moz-do-not-send="true" href="http://www.4offer.biz/"
target="_blank">http://www.4offer.biz/</a> -- <a
moz-do-not-send="true" 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 moz-do-not-send="true" href="http://2bits.com">2bits.com</a>, Inc.<br>
<a moz-do-not-send="true" 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>
</blockquote>
</body>
</html>