I have an observer listening to the controller_action_predispatch event. This is because I'm doing some geo ip related logic for each page customers are visiting. I want to show a light-box popup to get customer's input as a part of the logic.

Part of the issue that I'm facing here is at this stage layouts are not loaded. :(

Is this possible to do? If so whats the best efficient way of doing it?

有帮助吗?

解决方案 2

So I had to go with a different event to access the layouts from my Observer. Best one for me was listening to controller_action_layout_generate_blocks_after event. Then I grab a block,

$myblock = $observer->getLayout()->getblock('myblock');
$myblock->setMyvar('PassMyValue');

And then use that value to popup my light box to get the user input.

其他提示

Look at

Mage_Core_Controller_Varien_Action::renderLayout()

Mage::dispatchEvent('controller_action_layout_render_before');
Mage::dispatchEvent('controller_action_layout_render_before_'.$this->getFullActionName());

That event might work better

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top