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();
    }
}

This website stores cookies on your computer. These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media. To find out more about the cookies we use, see our Privacy Policy.