Created
March 25, 2015 08:51
-
-
Save dinhkhanh/0848fc27f2d145bf885d to your computer and use it in GitHub Desktop.
Magento - Manually add handle in controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
1. If you add your handle before you call $this->loadLayout() from a controller it’s too soon | |
2. 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('customizer_index_index'); | |
$this->loadLayoutUpdates(); | |
$this->generateLayoutXml(); | |
$this->generateLayoutBlocks(); | |
$this->_isLayoutLoaded = true; | |
//refer 1: http://stackoverflow.com/a/3506079/904711 | |
//refer 2: http://makandracards.com/magento/8209-adding-a-layout-handle-from-a-controller |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment