Covering Empty Block with Stack/Global Area

Permalink
Hello!

I have a function which covering empty block area with a stack/global area. But since C5 5.7.4.2 release, I can't use that function again, it said errors bla.bla.bla. when I try to call it from other theme files.

This is my function :
function coverBlock($block,$stack=null){
   if(empty($c)) global $c;
   $ts = $c->getBlocks($block);
   if (is_object($ts[0]) || $c->isEditMode()) {
      $as = new Area($block);
      $as->display($c);
   }else{
      $ga = Stack::getByName((empty($stack)?$block:$stack));
      $ga->display();
   }
}

placed in header.php.

Any ideas to make it works again ? May place it under page_theme.php ?

Thanks for advance :)

goesredy
 
ramonleenders replied on at Permalink Reply
ramonleenders
What about this code? I think you cannot retrieve the $c variable from a global anymore, that's where the error lies.

function coverBlock($block, $stack = null)
{
    $c = Page::getCurrentPage();
    $ts = $c->getBlocks($block);
    if (is_object($ts[0]) || $c->isEditMode()) {
        $as = new Area($block);
        $as->display($c);
    } else {
        $ga = Stack::getByName((empty($stack) ? $block : $stack));
        $ga->display();
    }
}