سؤال

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