2014-06-09

Debug layout updates in magento

For each request magento sees all layout updates (located at design layout folder) and find the appropriate handles. To get list of handles which appropriate to the current request you have to write in controller:
$this->loadLayout();
echo '<pre>';
print_r($this->getLayout()->getUpdate()->getHandles());
echo '</pre>';
exit;
The result will be something like that:
Array
(
    [0] => default
    [1] => STORE_default
    [2] => THEME_frontend_default_default
    [3] => catalog_category_view
    [4] => customer_logged_out
)
Then magento merges all layout updates for handles in the above array to one xml file. To show this file you have to write in controller (at the beginning of method):
header('Content-type: text/xml');
$this->loadLayout();
echo $this->getLayout()->getNode()->asXML();
exit;

No comments:

Post a Comment