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?

Marius
199k55 gold badges431 silver badges837 bronze badges
asked Jun 14, 2016 at 10:11

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());
}
answered Jun 14, 2016 at 10:45
1
  • @Jimmery: does this helps ? Commented 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.

answered Jun 14, 2016 at 10:47
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.

answered Jun 14, 2016 at 10:25

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.