XF 2.1 How to access data from the Alert repo inside a template?

asprin

Active member
I'm using the following the code to send an alert to a user:
PHP:
$userId = 1;
$user = \XF::app()->find('XF:User', $userId);
$alertRepo = \XF::app()->repository('XF:UserAlert');
$alertRepo->alert($user, 2, 'asprin', 'user', $user->user_id, 'vcash', array('won'=>54335));

This successfully inserts the $extra[] data in the table as shown below:
1579078918998.png

I created a template named alert_user_vcash with the following text:
1579078981113.png

The problem is that the alert does show up but without the $won value.
1579079044814.png


What am I missing here?
 
Variable name should be something like {$extra.won} or similar (don't have the exact one in my head rn, can look at existing templates).
 
Variable name should be something like {$extra.won} or similar (don't have the exact one in my head rn, can look at existing templates).
Works like charm! Wish there was an "accepted" solution sort of thing to indicate query has been answered. Would be helpful for others stuck in a similar situation.
 
Top Bottom