Notification templates usage

Nikolay 2 years 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 Tananaev2 years 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 2 years 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 2 years 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