Weird issue with outputting HTML in a template via variable

Jake B.

Well-known member
For the credits add-on we have created a feature a couple versions back that allow users to receive alerts when they earn/lose credits via the actions but it seems that if the prefix/suffix for your currency uses html it breaks in the alerts. Here is an example of how it is running:

Audentio_Credit_Core_AlertHandler_Action::renderHtml
Code:
        $item['templateTitle'] = $this->_getDefaultTemplateTitle($item['content_type'], $item['action']);
        $item['alertContent'] = new XenForo_Phrase('adcredit_alert_action_'.$item['action'], array(
            'subPhrase'    => new XenForo_Phrase('adcredit_alert_action_subphrase_'.$item['extra']['action']),
            'credits'    => $this->_getCreditModel()->formatCredits($item['extra']['amount'], $item['extra']['currency_id']),
        ));
        return $view->createTemplateObject($item['templateTitle'], $item);

Template:
Code:
{xen:raw $alertContent}

I do this as there can be many different actions, and i'd rather just have a phrase for each action instead of a separate phrase and template for every action's alert.

So in the alert instead of something like

You have earned $1,000 for blah

It'll show:
You have earned <span style="color: green">$1,000</span> for blah

even though I have the xen:raw in place. This displays properly everywhere except in alerts.
 
You'll probably want to pass false or array('subPhrase' => false) as the 3rd param to the outer new XenForo_Phrase
 
Back
Top Bottom