Set a remote tag without affecting the other tags?

Forgive a senile man: I can’t recall how to make a button that adds a tag without messing up the tags already there? If I use a the SetFieldWidget then the whole tag field will be replaced… and some venturing using a macro for concatenation and a WikifyWidget just didn’t work out… so what should I do?

Thinking about it… it would be useful with an ActionModifyFieldWidget to add/remove items (strings) in a field. Or some parameter in the ActionSetFieldWidget to state if an item should just be appended or removed form a field, rather than replace it all…

I think the actionlistops widget is what you’re looking for. There’s also a way to do it with message and the field mangler, but ALO is probably easier.

Ah, but of course! Forgot about actionlistops!
Thanks Mark.

There is also a separate set of action widgets relating to tags, ie not using the setfield widget.

WidgetMessage: tm-add-tag
WidgetMessage: tm-remove-tag

It would be great is these message widgets also accepted a “tag field” but as stated previously the ActionListopsWidget.

Remember the listops is about list operations primarily where the list items are titles. A core example is the way with tag reordering their is a list field created.

The key thing to recognise about the ActionListopsWidget is the use of the subfilter. After naming the tiddler and field you are targeting, the subfilter can contain +[[tag name]] or -[[tag name]] including +tagname and -tagname (if not spaces) but can get a lot more sophisticated. Including multiples and filters that generate the titles to be added and removed to the field.

This listops subfilter (and tag actions) can now include filters with the use the cycle Operator and toggle Operator. However for some time we have a larger set of filter operators for this very purpose see the items tagged “Listops Operators” at tiddlywiki.com;

{{{ [tag[Listops Operators]] }}}

Result
allafter Operator
allbefore Operator
append Operator
cycle Operator
insertbefore Operator
move Operator
prepend Operator
putafter Operator
putbefore Operator
putfirst Operator
putlast Operator
remove Operator
replace Operator
sortby Operator
toggle Operator
unique Operator

See also

  • {{{ [tag[Order Operators]] }}} to make use of the order of items, or use the sort and sortby at “run time” rather than changing the order in a list field.
  • Also as mentioned elsewhere if you want fully featured additional tag fields then see Gen Tags
2 Likes