Providing variables to notifications (tm-notify)

130 views
Skip to first unread message

Hubert

unread,
Oct 18, 2019, 6:03:59 AM10/18/19
to TiddlyWiki
Hello,

Widget message tm-notify makes it possible to provide variables to notifications:

paramObject: Hashmap of variables to be provided to the notification

Unfortunately, I could not get it to work; there's no further explanation as to what a hashmap would be, nor what format it would require, etc.

What I want to achieve is to be able to generate a notification that will include dynamically generated text: a single "notification" tiddler would be generated as a notification showing the variable value set from the tiddler that is sending the tm-notify message.

I know this could probably be done using global variables but I'm specifically interested in exploring the paramObject parameter / hashmap.

Any help or further explanation would be greatly appreciated.

Regards,
Hubert

PMario

unread,
Oct 18, 2019, 6:42:44 AM10/18/19
to TiddlyWiki
Hi,
Import the attachment and have a closer look.

It contains 2 tiddlers.

NotifyTemplate contains the text with the variables, test and test1 .... You should definitely give them better names!!!

test-notify contains a button, which defines the actions and the "variable hashmap" ... test and test1 are the "hashmap" parameters.

NotifyTemplate contains

<<test>> - <<test1>>

test-notify contains:

\define my-actions(a:"Hello", b:"World")
<$action-sendmessage $message="tm-notify" $param="NotifyTemplate" test="""$a$""" test1="""$b$""" />
\end

<$button actions=<<my-actions>> >Notify!</$button>



have fun!
mario

notify-variables-example.json

PMario

unread,
Oct 18, 2019, 6:44:50 AM10/18/19
to TiddlyWiki
Hi,

Changing the parameters looks like this:

<$button actions=<<my-actions b:"Hubert">> >Notify!</$button>

-m

Hubert

unread,
Oct 18, 2019, 7:39:34 AM10/18/19
to TiddlyWiki
PMario -- thank you very much! It works like a charm.

Best regards,
Hubert

PMario

unread,
Oct 18, 2019, 8:07:28 AM10/18/19
to TiddlyWiki
On Friday, October 18, 2019 at 1:39:34 PM UTC+2, Hubert wrote:
PMario -- thank you very much! It works like a charm.

That's nice!

Depending on the text, that you want to show, it may be needed to change the code like this:

\define my-actions(a:"Hello", b:"World")
<$action-sendmessage $message="tm-notify" $param="NotifyTemplate" test=<<__a__>> test1=<<__b__>> />

\end

<$button actions=<<my-actions>> >Notify!</$button>

This type of variable usage is needed, if eg: test or test1 are part of a filter in the NotifyTemplate. If you just need text, you should be fine with the first example.

-m


Mohammad

unread,
Oct 18, 2019, 11:06:31 AM10/18/19
to TiddlyWiki
Added to TW-Scripts.

Mohammad

unread,
Oct 18, 2019, 5:47:38 PM10/18/19
to TiddlyWiki

TonyM

unread,
Oct 19, 2019, 1:31:16 AM10/19/19
to TiddlyWiki
Perhaps tiddlywiki.com doco needs updating not to use the hashmap term as its not defined anywhere else and means nothing special other than a set of name=parameter pairs.
Reply all
Reply to author
Forward
0 new messages