Adding a tag to tiddler with existing tags

332 views
Skip to first unread message

Tony Grosinger

unread,
Jan 19, 2017, 12:00:48 PM1/19/17
to tiddl...@googlegroups.com

I am trying to create a button in a tiddler which adds a new tag to that tiddler. I have found a way to replace all the existing tags with the one specified, but I am having trouble getting the add-tag feature to work.

This example replaces all the tags and works.

\define mark-complete()
<$action-setfield tags="my-tag"/>
\end

<$button actions=<<mark-complete>>>Mark Complete</$button>

This example tries to just add a tag, but does not work.

\define mark-complete()
<$action-sendmessage $message="tm-add-tag" $param="my-tag"/>
\end

<$button actions=<<mark-complete>>>Mark Complete</$button>

Can someone point out what I am doing wrong? I have not used macros or widgets very extensively yet.
Thank you.

Tobias Beer

unread,
Jan 19, 2017, 1:56:39 PM1/19/17
to TiddlyWiki
Hi Tony,

It appears you may need the relic called FieldManglerWidget to get it to work:

I kinda wish we could get rid of it entirely (no more dependencies of other widgets to it).

Best wishes,

Tobias.


Jed Carty

unread,
Jan 19, 2017, 2:05:01 PM1/19/17
to TiddlyWiki
You can do this with the action-listops widget like this:

<$button>Do Eeet!!
<$action-listops $tiddler=HelloThere $field=tags $subfilter='+[append[Hello!!]]'/>
</$button>

if you put that in a tiddler on tiddlywiki.com it will add the tag Hello!! to the HelloThere tiddler and leave the TableOfContents tag in place.

Tony Grosinger

unread,
Jan 19, 2017, 2:39:59 PM1/19/17
to tiddl...@googlegroups.com
Jed, I read somewhere on tiddlywiki.com that I should favor defining a macro and calling it from the button rather than putting actions in the button. Is this just an exception?

Tobias, it sounds like tm-add-tag uses the fieldmangler under the covers. Are you proposing something different? If so can you provide an example?

Thank you both!

Jed Carty

unread,
Jan 19, 2017, 3:24:28 PM1/19/17
to TiddlyWiki
I don't know of any reason to favour using a macro instead of putting widgets in the button directly. So if that is recommended it is news to me.

And since I am answering anyway, the fieldmangler widget acts differently than most other widgets, you would use it like this:

<$fieldmangler tiddler=sometiddler>
<$button message=tm-add-tag param=SomeTag>
LOOK AT ME!! I am a button label!!
</$button>
</$fieldmangler>

I tend to avoid the fieldmangler widget.

Tony Grosinger

unread,
Jan 19, 2017, 3:37:29 PM1/19/17
to TiddlyWiki
Maybe I should expand a little on exactly what I am trying to accomplish.

I would like to make a button which can be very easily included in a large number of different tiddlers. This button would simply add a tag to that tiddler when clicked.

Or, in more concrete terms, I want to have tiddlers representing a task. These tiddlers have a tag "task". When I click the button, the tag "complete" would be added, allowing me to very easily filter on them.

Jed Carty

unread,
Jan 19, 2017, 3:46:19 PM1/19/17
to TiddlyWiki
Just remove the tiddler part and it will default to the current tiddler.

Using action-listops it would be like this:

<$button>DO EET!!
<$action-listops $field=tags $subfilter='+[append[Complete]]'/>
</$button>

and using the fieldmangler widget:

<$fieldmangler>
<$button message=tm-add-tag param=Complete>Add The Thing
</$button>
</$fieldmangler>

put either of those in a conditional view template and it should do what you want.

Tony Grosinger

unread,
Jan 19, 2017, 5:41:41 PM1/19/17
to TiddlyWiki

This is great, thank you Jed. Can I take this one step further?

I have now created a tiddler and marked it as a Macro.

\define mark-complete()
<$action-listops $field=tags $subfilter='+[append[Complete]]'/>
\end

Then in my task tiddlers I can just add a button which calls that Macro:

<$button actions=<<mark-complete>>>Mark Complete</$button>

Is there any clever way of easily creating new tasks without having to remember to type that in each time? Creative solutions are fine. Maybe that means a button in the sidebar that somehow generates a new tiddler? Maybe there is some way to use templates that I haven’t thought of? Just wondering what a TiddlyWiki expert might be able to think of.

Tobias Beer

unread,
Jan 20, 2017, 2:04:04 AM1/20/17
to TiddlyWiki
Hi Tony,

I don't see any reason to have the button actions and the button be in separate tiddlers.
 

Is there any clever way of easily creating new tasks without having to remember to type that in each time? Creative solutions are fine. Maybe that means a button in the sidebar that somehow generates a new tiddler? Maybe there is some way to use templates that I haven’t thought of? Just wondering what a TiddlyWiki expert might be able to think of.

You can display your button for any or all tiddlers using a


The same technique works for any template components, e.g. toolbar buttons.

To create a task from a more sophisticated template, you can use a button with one, e.g:

Create Tiddler From Template

This explains how you get your own button in the sidebar or tiddler toolbar or wherever you want it.

Best wishes,

Tobias.

Jed Carty

unread,
Jan 20, 2017, 2:25:40 AM1/20/17
to TiddlyWiki
I made a basic task list a while ago that may have the part you want. Hopefully copying out the part that creates tasks is simple, I haven't looked at it in a long time. I imagine you could put it in a tab on the sidebar to make it easily available. http://inmysocks.tiddlyspot.com/#%24%3A%2Fplugins%2Finmysocks%2FMinimalTaskList%2FMinimal%20Task%20List

Tony Grosinger

unread,
Jan 20, 2017, 11:24:23 AM1/20/17
to TiddlyWiki
Wow Tobias,
That wiki is a gold mine. Thank you very much.
Reply all
Reply to author
Forward
0 new messages