Only generate flexiblock divs if blocks are assigned to them.
drupal steve - June 8, 2006 - 01:48
I am using the flexiblock module v1.8 with drupal v4.6.6. I would like to use some php code in my page.tpl.php which checks for the assignment (or not) of any blocks to each flexiblock region before generating the flexiblock divs. (I have no need for flexiblock divs where there are no blocks are assigned to them.)
Any ideas? I hope I have given enough description of my situation and request for assistance.
Regards,
-Steve

Count me in for this
I would be interested to know how to do this myself. I am hardly a coder but, right now I am trying to work with the code:
<?php if ($block['content'] ) { ?> <div id="subnav"><?php $blocks = theme('flexiblock_blocks', 'area3'); ?>
<?php foreach ( $blocks as $block ) { ?>
<?php echo $block['content'] ?>
<?php } ?><?php } ?>
</div>
However, this is not working. I'm not really sure what needs to be in the if statement, or where it has to be placed.
I'd be interested to find out!
-txcrew
I think I got it
I think I got it now, just had it in the wrong place. Again, not sure if this is the best way to do this but it worked for me:
<?php $blocks = theme('flexiblock_blocks', 'area3'); ?><?php foreach ( $blocks as $block ) { ?>
<?php if ($block['content'] ) { ?> <div id="subnav"><?php echo $block['content'] ?>
</div><?php } ?><?php } ?>
Hope this helps,
txcrew
Working in drupal 4.6.6 and 4.7.2
This doesn't look very elegant, but it's functional
For drupal 4.6.6,
<?php $flexiblock1 = theme('flexiblock_blocks', 1); ?><?php foreach ( $flexiblock1 as $block ) { ?><?php $flexiblock1content = $block['content']; ?><?php } ?>
<?php if ($flexiblock1content != ""): ?>
<div id="flexiblock1">
<?php $blocks = theme('flexiblock_blocks', 1); ?>
<?php foreach ( $blocks as $block ) { ?>
<div class="content"><?php echo $block['content'] ?></div>
<?php } ?></div>
<?php endif; ?>
This makes more sense... Using drupal 4.7.2's theme-specific regions feature,
<?php if ($block1) { ?><div id="block1"><?php print $block1 ?></div><?php } ?>Steve Oliver
Creative Director
Oliver Associates, Inc.