Last active
December 10, 2015 07:28
-
-
Save jacquesbh/4401568 to your computer and use it in GitHub Desktop.
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 | |
Zend_Debug::dump(Mage::app()->getLayout()->getUpdate()->getHandles()); |
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 | |
abstract class Mage_Core_Controller_Varien_Action | |
{ | |
/* .. */ | |
/** | |
* Load layout by handles(s) | |
* | |
* @param string $handles | |
* @param string $cacheId | |
* @param boolean $generateBlocks | |
* @return Mage_Core_Controller_Varien_Action | |
*/ | |
public function loadLayout($handles=null, $generateBlocks=true, $generateXml=true) | |
{ | |
// if handles were specified in arguments load them first | |
if (false!==$handles && ''!==$handles) { | |
// The $handles can be a string or an array | |
$this->getLayout()->getUpdate()->addHandle($handles ? $handles : 'default'); | |
} | |
/* | |
* Add default layout handles for this action | |
*/ | |
//$this->addActionLayoutHandles(); | |
// -- copy of addActionLayoutHandles() -- | |
$update = $this->getLayout()->getUpdate(); | |
// load store handle | |
$update->addHandle('STORE_'.Mage::app()->getStore()->getCode()); | |
// load theme handle | |
$package = Mage::getSingleton('core/design_package'); | |
$update->addHandle('THEME_'.$package->getArea().'_'.$package->getPackageName().'_'.$package->getTheme('layout')); | |
// load action handle | |
// The method getFullActionName() returns "frontname_controller_action" in our example | |
$update->addHandle(strtolower($this->getFullActionName())); | |
// -- endcopy of addActionLayoutHandles() -- | |
/* | |
* Load the updates of the Layout | |
*/ | |
//$this->loadLayoutUpdates(); | |
// -- copy of loadLayoutUpdates() -- | |
// dispatch event for adding handles to layout update | |
Mage::dispatchEvent( | |
'controller_action_layout_load_before', | |
array('action'=>$this, 'layout'=>$this->getLayout()) | |
); | |
// load layout updates by specified handles | |
$this->getLayout()->getUpdate()->load(); | |
// -- endcopy of loadLayoutUpdates() -- | |
if (!$generateXml) { | |
return $this; | |
} | |
$this->generateLayoutXml(); | |
if (!$generateBlocks) { | |
return $this; | |
} | |
$this->generateLayoutBlocks(); | |
$this->_isLayoutLoaded = true; | |
return $this; | |
} | |
/* .. */ | |
} |
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 | |
class Mon_Module_Model_Observer | |
{ | |
/** | |
* Add handles before the layout xml generation | |
* @param Varien_Event_Observer $observer | |
* @return void | |
*/ | |
public function layoutLoadBefore(Varien_Event_Observer $observer) | |
{ | |
if ($action = $observer->getAction()) { | |
Mage::dispatchEvent( | |
'controller_action_layout_load_before_' . $action->getFullActionName(), | |
$observer->getData() | |
); | |
} | |
} | |
} |
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 | |
class Mon_Module_Model_Observer | |
{ | |
/** | |
* Add handles before the layout xml generation | |
* @param Varien_Event_Observer $observer | |
* @return void | |
*/ | |
public function layoutLoadBefore(Varien_Event_Observer $observer) | |
{ | |
if ($action = $observer->getAction()) { | |
switch ($action->getFullActionName()) { | |
case 'frontname_controller_action': | |
$observer->getLayout()->getUpdate()->addHandle('MON_NEW_HANDLE'); | |
break; | |
} | |
} | |
} | |
} |
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 | |
class Mon_Module_Model_Observer | |
{ | |
/** | |
* Add handles before the layout xml generation | |
* @param Varien_Event_Observer $observer | |
* @return void | |
*/ | |
public function layoutLoadBefore(Varien_Event_Observer $observer) | |
{ | |
if ($action = $observer->getAction()) { | |
switch ($action->getFullActionName()) { | |
case 'frontname_controller_action': | |
$news = Mage::registry('current_news'); | |
if ($news->getId()) { | |
$observer->getLayout()->getUpdate()->addHandle('MON_MODULE_ACTION_NEWS_TYPE_' . $news->getType()); | |
} | |
break; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment