Hide an empty area

Permalink 1 user found helpful
How can I hide an empty area?

Fxxxx
View Replies: View Best Answer
Remo replied on at Permalink Reply
Remo
Not sure what you're trying to achieve. When you're editing a page you have to see the area, otherwise you can't put any content in it and could simply remove that area. When you've published the page, an empty area shouldn't matter either since you won't see anything if there aren't any blocks in it.

Can you please explain what you're trying to do? Might help us to help you (:
mesuva replied on at Permalink Reply
mesuva
I'll take a stab at this:

<?php 
$a = new Area('Area');
if ($a->getTotalBlocksInArea($c) > 0 or $c->isEditMode()) {
?>
<div id="area">   
<?php    $a->display($c); ?>
</div>
<?php } else {
    $a->display($c);   
} ?>
Fxxxx replied on at Permalink Reply
Fxxxx
I use this code
<div id="sidebar">
<?php
   $a = new Area('Sidebar');
   $a->setBlockWrapperStart('<div class="box-sidebar">');
   $a->setBlockWrapperEnd('</div>');
   $a->display($c);
?>
</div>

but the sidebar has a background... so even if in sidebar there aren't any blocks tha sidebar appears...
Remo replied on at Permalink Reply
Remo
Okay, so it's the wrapper code you want to hide.

Just use the above from Mesuva and wrap your sidebar in it!
Fxxxx replied on at Permalink Reply
Fxxxx
Can you write the code...
Thank you
mesuva replied on at Permalink Best Answer Reply
mesuva
<?php 
$a = new Area('Sidebar');
$a->setBlockWrapperStart('<div class="box-sidebar">');
$a->setBlockWrapperEnd('</div>');
if ($a->getTotalBlocksInArea($c) > 0 or $c->isEditMode()) {
?>
<div id="sidebar">   
<?php    $a->display($c); ?>
</div>
<?php }  ?>
mesuva replied on at Permalink Reply
mesuva
Just edited this, realised I didn't need the else clause.
Fxxxx replied on at Permalink Reply
Fxxxx
Thank you!