danielhpavey.uk

A sorta, kinda, web development and design blog...

Find Magento Layout Handle for Current Controller/Action

I is still getting the hang of the whole Magento layout functionality but have just found a couple of tips that have helped me greatly.

As I understand it the layout handle of and xml file is the node that is called when a particular page is loaded by Magento.

Eg. in a layout xml file your might find a section marked as

This would correspond to the webpage /forms/contact/success.

You would then configure the layout element for that page within that section of that xml file.

However if you are working on a custom module ore something similar and are unsure which layout your controller is trying to load you can use the following code to dubug:

$this->loadLayout();
$this->renderLayout();
Zend_Debug::dump($this->getLayout()->getUpdate()->getHandles());

If you pop that in your controller it will output some info which will tell your which layout is or should be getting loaded.

Friday 3 February 2017

Tags: #magento #web development #php