Get block attribute value in phtml

Get block attribute value in phtml

Add block in your CMS page or CMS block

{{block type="Myvendor\Mymodule\Block\Index" template="Myvendor_Mymodule::index.phtml" deskdisplay="4" tabletdisplay="2" mobiledisplay="1"}}

In Your phtml file get the attribute value.

echo $deskDisplay = $block->getData("deskdisplay");

Related Post : Create enquiry form in Magento 2

Like us on Facebook and Linkedin for more updates.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top