Button snippet needed

Hi everyone

I need a button that adds the tag ‘foo’ to every tiddler that already has tag ‘bar’ but does not have ‘foo’. Use case: a ‘reset’ button for daily to do tasks that I untag as I finish them. I don’t want a toggle solution, because the tasks I didn’t finish and untag should stay visible in the list after clicking the reset button.

I think if I see the snippet, I can also figure out how to create a button that deletes ‘foo’ from a given tiddler in the list.

Thanks in advance, Dave

I am looking at something similar in tags with [RFC] Alternative display of tags in view template - conditional tag display - #2 by TW_Tones I will see what I can do in 8 or so hours if no one has yet.

Just a stupid comment from your idiot friend.

I have NO idea who “foo” & “bar” are!

I DO realise a lot of folk have the HOTS for that lingo …

… but, what is that lingo about?

Innocent question.
TT, x

1 Like

you can use <$action-listops $tags="foo"/> to add the tag “foo” to the current tiddler
you can use <$action-listops $tags="-foo"/> to remove the tag “foo” from the current tiddler
Note that these only add/remove tag “foo”, without affecting any other tags on the tiddler

Thus, you can create a $button like this:

<$button> add tag "foo" to tiddlers tagged with "bar"
   <$list filter="[tag[bar]!tag[foo]]"><$action-listops $tags="foo"/></$list>
</$button>

Note that it isn’t really necessary to use !tag[foo] in the filter, since using $action-listops will only result in the “foo” tag occur once in each tiddler’s tags. Thus, you could simplify the filter to just:

<$list filter="[tag[bar]]"><$action-listops $tags="foo"/></$list>

ref: https://tiddlywiki.com/#ActionListopsWidget

enjoy,
-e

1 Like

Not a clue, @TiddlyTweeter!

1 Like

“foo”, “bar”, and other nonsense words are often used in discussions of computer programming as placeholders for non-specific values in example code.

see Metasyntactic variable - Wikipedia

I personally have used the following list of nonsense words:
foo, bar, baz, mumble, frotz, gronk, snork, snerfle, plurm

Also note that the word “foobar” is a variant spelling of the military acronym FUBAR which stands for:
“F**ked Up Beyond All Recognition”

Saving Private Ryan:

-e

1 Like

Thanks for explaining the obvious to me.
I appreciate it!

I don’t think it is that obvious often?

TT

Thank you, Eric!

I was able to figure out the other part, too! I may share my new little toy here later.

1 Like

Okay, one last question, @EricShulman or anyone else: Inside a list of tiddlers filtered by tags, I want to have, for each entry, a button to delete that tiddler. I tried using the two snippets below, but they don’t work. What am I doing wrong?

<$button><$action-deletetiddler tiddler={{!!title}} />&nbsp;x</$button>

<$button><$action-deletetiddler />&nbsp;x</$button>

<$button>{{$:/core/images/delete-button}}
   <$action-deletetiddler $tiddler={{!!title}}/>
</$button>

Notes:

  • The $action-deletetiddler parameter name needs to start with a $
  • Although the documentation (https://tiddlywiki.com/#ActionDeleteTiddlerWidget) appears to imply that $tiddler and $filter parameters are both optional, you must specify one of them. Omitting both does NOT default to the <<currentTiddler>> value.
  • I replaced your button label text (&nbsp;x) with a transclusion of the TWCore image of a trash can.

Thanks Eric! Works great!

From Wikipedia:

It is possible that foobar is a playful allusion to the World War II-era military slang FUBAR

Ehffed up beyond all recognition.

I discovered FUBAR via one of my favorite movies, Full Metal Jacket.