Empty blocks

Permalink
Hi! I've learnt to use the code
<?php
$a = new Area('Sidebar');        
if ($a->getTotalBlocksInArea($c) > 0) { ?>
   <div id="sidebar">
   <?php $a->display($c); ?>
   </div>
<?php } else { ?>
<?php $a->display($c); ?>
<?php } ?>

That prints out the sidebar DIVs only if there is a blocks in this area.

Now I would wan't the sidebar to show up depending on if there's blocks in the Main-area, so instead of
if ($a->getTotalBlocksInArea($c) > 0) { ?>

I use
if ($a->getTotalBlocksInArea('Main') > 0) { ?>


but I won't get it to work. Any ideas???

 
xandre replied on at Permalink Reply
Changed the code a little bit, I messed up with my first post.

Hope somebody can help me with this :(
synlag replied on at Permalink Reply
synlag
http://www.concrete5.org/help/building_with_concrete5/developers/mvc/scripting_common_concrete5_tasks/

$c = new Page::getByPath('/yourpagepath');
$blocks = $c->getBlocks("Main");
tolga replied on at Permalink Reply
tolga
<div id="showcase">
   <div id="showcase_inner" class="center_wrapper clearfix">
      <?php
           $a = new Area('Showcase');
           $a->display($c);
        ?>
   </div>
</div>
<?php
if ($a->getTotalBlocksInArea($c) > 0 ) {
?>
   <style type="text/css">
      #showcase { height:220px; display:block; }
   </style>
<?php } ?>