cancel
Showing results for 
Search instead for 
Did you mean: 

How to get a block's alias (as) programmatically

SOLVED

How to get a block's alias (as) programmatically

Hello,

 

I'm trying to get some info about block in an observer but I haven't been able to get the alias (or 'as' parameter in layout xml). I've tried several different things without success. Here is a look at my (partial) code:

public function getBlockInfo(
        \Magento\Framework\View\Element\BlockInterface $block,
        $fullInfo = true
    ){
        $info = array(
            'name' => $block->getNameInLayout(),
            'alias' => '', //TODO: Add block alias to list
        );
return $info; }

Can anyone help me out here ?

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions

Re: How to get a block's alias (as) programmatically

How to use the Magento 2 layout's getElementAlias() method to get the alias of a block or a contaner? https://mage2.pro/t/700

View solution in original post

2 REPLIES 2

Re: How to get a block's alias (as) programmatically

How to use the Magento 2 layout's getElementAlias() method to get the alias of a block or a contaner? https://mage2.pro/t/700

Re: How to get a block's alias (as) programmatically

Thank you, worked like a charm Smiley Happy