Doing this is a slight pain, to quote what Alan Storm said on StackOverflow Show archive.org snapshot :
- If you add your handle before you call $this->loadLayout() from a controller it's too soon
- If you add your handle after you call $this->loadLayout() it's too late
So, if you really need to add a handle to a controller, you need to replace the call to $this->loadLayout()
with:
$update = $this->getLayout()->getUpdate();
$update->addHandle('default');
$this->addActionLayoutHandles();
$update->addHandle('your_handle');
$this->loadLayoutUpdates();
$this->generateLayoutXml();
$this->generateLayoutBlocks();
$this->_isLayoutLoaded = true;
Posted by Mike Whitby to Magento (2012-04-30 13:58)