Magento – get custom layout update of CMS Page
Magento offers Custom Layout Update in the CMS page, that allows to add or remove any dynamic or static block in the CMS page. For example on the Home page we display featured products block or most viewed products block etc. For debugging purpose, many a time we need to track which blocks are added or removed using the Custom Layout Update in the CMS page. We can display the custom layout in XML format on a template page, using the following code.
Why display layout xml?
This will return the custom xml layout saved with the cms. Displaying Custom Layout Update will help us to observe the blocks and templates being used in this cms page. Analyzing these blocks or templates, we can evaluate the load on the page or cause of any other error.
For testing purpose paste this code in the app/design/frontend/package/theme/template/page/html/footer.phtml.
<?php //check if CMS page if(Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms'){ //display layout update xml echo "<pre>"; echo $custom_layout_xml = Mage::getSingleton('cms/page')->getLayoutUpdateXml(); echo "</pre>"; } ?>
Sample of returned xml
This code will return the XML similar to this. Obviously yours will be different.
<pre> <reference name=”right”> <action method=”unsetChild”><alias>right.reports.product.viewed</alias></action> <action method=”unsetChild”><alias>right.reports.product.compared</alias></action> </reference> </pre>