Notification templates usage

Nikolay a year ago

Hello, friends,

I would like to ask what is the correct way to use notification templates.

Now I create a computed attribute of type alarm and set a string there, for example 'tow'.

I create a notification type alarm and set tow for alarms.

Everything works, but I need to work with alarm.vm

How do I make it so that I use tow.vm instead of alarm.vm

Thanks

Anton Tananaeva year ago

You can't because there's only one template for alarms, but you can write the code in the template to display different things depending on the alarm type. Something like this:

#set($alarmName = $position.getString("alarm"))
#if($alarmName == "tow")
    ...
#elseif($alarmName == "sos")
    ...
Nikolay a year ago

Yep, this is my way too, but things get very ugly when I format more types.

Would it be possible to use Include or Parse?

Nikolay a year ago

Looks like it works.
If I create a tow.vm, make changes and parse it the way below, things work.

#elseif($alarmName == "tow")
  #set($alarmName = "tow")
  #parse( "./short/tow.vm" )
  #stop