Controling block display
weldonc - March 27, 2008 - 18:35
I have a block that displays ‘announcements,’ now I want to control when the block displays by creating a php code that will check if there is an announcement and if so then it will display it on a given page.
Thank you for your help in advance

Try this...
I’m assuming that announcement is a content type.
Copy your block.tpl.php to block-announcement.tpl.php then edit it to have
<?phpif ($block->content) :
?>
<?phpendif;
?>
Haven’t tested this, but I think that is the approach you need.
___________________
It’s in the detaιls…
Thank you
Thank you
So it did not work like I
So it did not work like I wanted it to below is the code I was trying:
<?phpif ($block->content){
return TRUE; // block will be shown
}
return FALSE;
?>
A typical block.tpl.php
You haven’t confirmed that announcement is a content type. You don’t say where you put this code.
Try following these instructions: A typical block.tpl.php looks like this;-
<div class="<?php print "block block-$block->module" ?>" id="<?php print "block-$block->module-$block->delta"; ?>"><div class="title"><h3><?php print $block->subject ?></h3></div>
<div class="content"><?php print $block->content ?></div>
</div>
<?php if ($block->content) :?><div class="<?php print "block block-$block->module" ?>" id="<?php print "block-$block->module-$block->delta"; ?>">
<div class="title"><h3><?php print $block->subject ?></h3></div>
<div class="content"><?php print $block->content ?></div>
</div>
<?php endif; ?>
___________________
It’s in the detaιls…