5

How do I discover the XML Layout name for a page?

Eg. <catalog_category_default> is the name for a default (non-layered) category page, <cms_index_index> is the name of a CMS Page.

I have several modules that are creating pages, and I would like to know what the XML Layout name for these pages are, or indeed, any page.

I was hoping that enabling Add Block Names to Hints under Developer > Debug in the System Configuration area would give me these page names, but they only seem to give me the name of the blocks used within that page.

Can anyone help?

3 Answers 3

6

To get current layout handle, use :

Zend_Debug::dump($this->getLayout()->getUpdate()->getHandles()); exit;
//OR    
var_dump(Mage::app()->getLayout()->getUpdate()->getHandles());exit;

In controller action, use can use it like :

public function indexAction()
{
        $this->loadLayout();
        $this->renderLayout();
        Zend_Debug::dump($this->getLayout()->getUpdate()->getHandles());
}
1
  • @Jimmery: does this helps ? Jun 18, 2016 at 5:56
4

Agreed with the great @Marius and you can also find a handler for a page from a class of body tag.

for example for home page if you check for a source of page you will find it like enter image description here

you need to just replace - with _ i.e. cms-index-index becomes cms_index_index

Hope this helps you.

1

you can add this line in the controller and you will see the layout handle name on the screen:

echo $this->getFullActionName();

This will give you the layout handle specific for the action, but there are other layout handles that are loaded dynamically depending on the state.
catalog_category_default, catalog_category_default, customer_logged_in, customer_logged_out are just a few examples.
Also PRODUCT_TYPE_simple, PRODUCT_TYPE_configurable,... for products.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.