In my observer function, I get a variable passed by the event like that:
public function observerFunc(Varien_Event_Observer $observer)
{
$sth = $observer->getEvent()->getSth();
}
If sth
is an object, I can alter it by calling methods on it. But how can I alter sth
if it is a simple string? I tried the following without success:
public function observerFunc(Varien_Event_Observer $observer)
{
$sth = $observer->getEvent()->getSth();
$observer->getEvent()->setSth('test');
$observer->setSth('test');
}
I just learned that some events also pass a transport object in which the string can be altered (thanks Alex), but the event page_block_html_topmenu_gethtml_after
does not. So what can I do?
The event in question gets dispatched like this and I want to alter $html:
$html = $this->_getHtml($this->_menu, $childrenWrapClass);
Mage::dispatchEvent('page_block_html_topmenu_gethtml_after', array(
'menu' => $this->_menu,
'html' => $html
));