Is it possible to check if a subArea contains blocks?

Permalink
Hi There,

Is there a way to check if a subArea contains blocks before outputting markup when using the Area Splitter add-on?

Have been trying stuff like this but don't understand how to make it work sorry:
<?php
  defined('C5_EXECUTE') or die("Access Denied.");
  $c = Page::getCurrentPage();
  $this->controller->setArea($this->area);
?>
<div class="box">
  <? if (($this->controller->subArea()->getTotalBlocksInArea($c) != 0) || ($c->isEditMode())) : ?>
  <div class="box-header">
    <?php $this->controller->subArea(); ?>
  </div>
  <? endif; ?>
  <? if (($this->controller->subArea()->getTotalBlocksInArea($c) != 0) || ($c->isEditMode())) : ?>
  <div class="box-footer">
    <?php $this->controller->subArea(); ?>
  </div>

Also, each time we place this into the Area Splitter template:
$this->controller->setArea($this->area);


It creates another area in edit mode - so because of the if statements, we actually see 4 sub areas when in edit mode - 2 actual sub areas and 2 extra from the if statements.

Any pointers in the right direction would be much appreciated.

Cheers

Ben

View Replies: