Earlier today in the TiddlyWiki Discord server (see https://discord.com/invite/HFFZVQ8), @gavcloud asked:
As this seems to be a relatively common question that has been asked before, I’m sharing my reply here:
First, edit shadow tiddler $:/core/ui/EditTemplate
. In the “save-tiddler-actions()” macro definition, add <<save-tiddler-custom-actions>>
just before the <<delete-edittemplate-state-tiddlers>>
.
Then, create a new tiddler (e.g., “MyCustomSaveActions”), tagged with $:/tags/Global
, and enter the following wikitext code:
\define save-tiddler-custom-actions()
<$list filter="[<currentTiddler>tag[Bookmark Tag]]" variable=none>
<$action-sendmessage $message="tm-add-field" $name="view" $value="[sort[title]]"/>
</$list>
\end
Now, whenever the core save-tiddler-actions()
macro is triggered by pressing the “done” button or by using the ctrl-enter keyboard shortcut, your save-tiddler-custom-actions()
macro will also be invoked… and, if the tiddler is tagged with “Bookmark Tag”, the tm-add-field
action will automatically add a view
field containing [sort[title]]
.
Of course, this technique can be used to add all sorts of “automatically create/set a field” handling side effects when saving a tiddler… and, if you want to “automatically add a tag”, you can use a tm-add-tag
message instead of (or in addition to) the tm-add-field
message:
<$action-sendmessage $message="tm-add-tag" $param="sometag"/>
enjoy,
-e