getAreaHandle() not returning correct handle (in GLOBAL area)

Permalink
The following code does not return the correct area handle (concrete 5.6.3.3)

$areaname = $this->block->getAreaHandle();


In a global area, this will return "main". The ONE AND ONLY time it will display correctly, is when I go in edit mode, click on the block, and click save and the view gets reloaded. So initially, the value returned by this function is incorrect, but after saving it is not... Can someone tell me what I could use as an alternative (as this clearly seems to be a bug)?

Thanks in advance.

P.S. Not sure if the same thing happens in 5.7, but this project is specifically in 5.6...

ramonleenders
 
weetheme replied on at Permalink Reply
weetheme
if ( $this->block->isBlockInStack() ) {
           $co=$this->block->getBlockCollectionObject();
            $arHandle = $co->getStackName();
        } else {
          $arHandle=$this->block->getAreaHandle();
        }
weetheme replied on at Permalink Reply
weetheme
if ( $this->block->isBlockInStack() ) {
      $co=$this->block->getBlockCollectionObject();
      print_r($co);
      if (is_a($co,'Page')){
         // in case when saved the block in edit mode
         $blockAreaHandle = $this->block->getAreaHandle();
      }
   if (is_a($co,'Stack')){
      $blockAreaHandle = $co->getStackName();
   }
 } else {
   $blockAreaHandle=$this->block->getAreaHandle();
 }