Magento – How to determine all blocks and child blocks attached to a handle

blockslayout

Is there a way to determine which blocks are attached to a handle and/or what child-blocks a block have?

Best Answer

To get all handles see Mage_Core_Model_Layout_Update::getHandles()

For example inside a controller you can use it for debugging purposes like:

Zend_Debug::dump($this->getLayout()->getUpdate()->getHandles());

Note: use it after loadLayout or loadLayoutUpdates call

To get all block children see Mage_Core_Block_Abstract::getChild() without parameters Note: the getChild() returns all child blocks as an object so used something like

Zend_Debug::dump(array_keys($block->getChild())) 

and you get an array with child block alias names

and if you want to see more about a block use

Zend_Debug::dump($block->getChild($aliasName))
Related Topic