public function onMailSimpleTemplateBeforeParse(Am_Event $event) { $template = $event->getTemplate(); $body = $event->getBody(); $subject = $event->getSubject(); foreach (array('user', 'affiliate') as $prefix) { if (strpos($body, "%{$prefix}.aff_link%") !== false) { $user = $this->getDi()->userRecord->fromRow($template->{$prefix}); $tmp = $template->{$prefix}; $tmp['aff_link'] = $this->getGeneralAffLink($user); $template->{$prefix} = $tmp; } } }