I’ve promised a few people that I would collate various snippets of useful Concrete5 code that I’ve used over the years. I feel somewhat obliged to since it seems that an awful lot of people have taken to this CMS on my recommendation.
You might notice the irony of posting this on a WordPress blog. I’m not happy about it, but the theme was just about acceptable and so that sold it. It will be migrated to a C5 instance in the near future.
On to the code.
If you have used C5, you will know what an area is and how it works. Let’s say you want to show some default content while that area contains no blocks, and then hide that content once someone has added some content.
$a= new Area('Main');
if ($c->isEditMode() || $a->getTotalBlocksInArea($c) > 0 )
{
$a->display($c);
}
else
{
echo 'This area is empty';
}