Magento 2 – how to view available blocks from a template

Posted on February 4, 2020 by jamie

All the blocks in the layout are huge objects that have references to other huge objects and at one point you get a circular reference an var_dump crashes.
If you want to get the names of the available blocks do this:


then if you find the key you need you can just print it out like this:

echo $this->getLayout()->getBlock('KEY HERE')->toHtml();

You can even call the line above without knowing if the block exists but call it a little different:

if ($block = $this->getLayout()->getBlock('KEY HERE')) {
    echo $block->toHtml();