Amsive

PUBLISHED: Feb 2, 2012 1 min read

Loading Blocks

Tom DiDomenico

Tom DiDomenico

Senior Vice President, Digital Strategy & Technology

Sometimes I’m banging my head against the wall trying to figure out why my block isn’t loading right or some other layout element isn’t rendering.  And I’ve always wished I could just see the layout as Magento is seeing it.  So I finally dug in to see and it’s actually incredibly simple to output the layout for a given page in xml format.

echo Mage::app()->getLayout()->getNode()->asNiceXml(”, 0);

The layout is just a Varien_Simplexml_Config.  getNode buys you access to the private $_xml variable that holds the root node of the xml document.  Then asNiceXml formats it nicely for the screen.  If you’d rather output to a file (they can be large chunks of xml) supply a file name for the first parameter of asNiceXml and the xml will be written there, too.

Now back to why my block isn’t loading…

Share: