Magento 2 – Get CMS Block Parameter in Block Class

blockscms-blockmagento2

How can i get this "cat" parameter from my cms page block

{{block class="Magento\Framework\View\Element\Template" template="Altravista_Carousel::product/carousel.phtml" cat="3"}}

in my Block Class?

Altravista\Carousel\Block\Product.php;

Best Answer

You can use in like this

{{block class="Magento\Framework\View\Element\Template" template="Altravista_Carousel::product/carousel.phtml" cat="3"}}

Now you can get the data by calling:

$myVar = $block->getData('cat');

OR

$myVar = $block->getMyCat();

Note : You should use $block.

Related Topic