iFuel Announces Launch of A2C Platform for Ecommerce Alcohol Sales. Read More

Loading Blocks

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…

TAGS: BlocksMagentoxml

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>