Some list questions

108 views
Skip to first unread message

jay

unread,
Jul 10, 2020, 5:23:01 AM7/10/20
to TiddlyWiki
Hey

So I'm a musician, I've been using tiddlywiki to keep a record of my performances, setlists, practice etc.

Each week I prepare and perform a 30 minute gig.

I have tiddlers for each performance, tagged /m/performance, and tiddlers for each song are tagged /m/song

I use the /m/performance tiddler to help me prepare for gigs and as a log of songs what I've performed. The naming convention for the title of these tiddlers is the date of the show followed by the venue. 

There are 2 things i want to do with lists that I can't figure out.

1) When assembling the setlist for a performance I can generate a list of all the songs in my repotoire on the /m/performance tiddler. I want a checkbox next to each link tha,t if selected, will tag the song with the title of the performance tiddler (or link it with the performance tiddler in some other way). This is the code I'm currently using in the template for my /m/performance tiddlers but if I check the box the song is tagged with its own title (name of the song), not the title of the performance tiddler.

<$list filter="[tag[/m/song]]">
<$checkbox tag=<<currentTiddler>> /> <$link to={{!!title}}><$view field="title"/></$link><br>
</$list>

2) I will next create a list of all songs tagged with the performance. These will be the pieces that I work on during the week. Thats fine I can do that. But I'd also like to be able to drag and drop / rearrange this list  in view mode, as it becomes the final setlist for the gig. I'd also like to be able to preserve that order. Not sure how to make any of this happen?

I hope this makes sense, any thoughts on any of these problems would be helpful.


si

unread,
Jul 10, 2020, 5:11:36 PM7/10/20
to tiddl...@googlegroups.com
Hi Jay.

1) Your problem here is that by default the list widget stores the title of each tiddler that it lists in the <<currentTiddler>> variable. One solution is to use the set widget to set a new variable to the title of the /m/performance tiddler before invoking the list widget, like this:

<$set name="performance" value=<<currentTiddler>> >
<$list filter="[tag[/m/song]]">
<$checkbox tag=<
<performance>> /> <$link to={{!!title}}><$view field="title"/></$link><br>
</$list>
</$set>

2) Here you can use the list-tagged-draggable macro:

<<list-tagged-draggable tag:"the title of the performance tiddler">>

If you want to use a variable for the value of the tag (for example <<currentTiddler>>), you will need to use the Macro Call widget:

<$macrocall $name="list-tagged-draggable" tag=<<currentTiddler>> />

Hopefully that helps!

jay

unread,
Jul 10, 2020, 6:23:39 PM7/10/20
to TiddlyWiki
Hey, thank you so much for your explanation. I hadn't heard of the set widget before, very useful.

Have a great day

Eric Shulman

unread,
Jul 10, 2020, 9:15:55 PM7/10/20
to TiddlyWiki
On Friday, July 10, 2020 at 3:23:39 PM UTC-7, jay wrote:
I hadn't heard of the set widget before, very useful.

There is also a more compact syntax for setting variables: the <$vars> widget.
It is particularly useful when you are setting multiple variables.
Using <$set>, you need one widget for each variable, like this:
<$set name="foo" value=...>
<$set name="bar" value=...>
<$set name="baz" value=...>
  ... your code here...
</$set>
</$set>
</$set>
with a matching </$set> for each.

Using <$vars> you can define multiple variables with a single widget:
<$vars foo=... bar=... baz=...>
  ... your code here ...
</$vars>

and a single matching </$vars>

For setting of simple variables, I always use <$vars> instead of <$set>.

One exception is when you want to use the <$set filter="..."> syntax to
capture an entire list of items into a single variable, like this:
<$set name="matches" filter="[tag[foo]]">
...
</$set>

Using the above syntax, you can get a space-separated list of all titles tagged with "foo",
and store it in a single variable, "matches".

You can also use <$set> to make "conditional assignments".  For example, suppose you
want to set a value based on whether or not a filter returns any results.  In that case, you
can write something like:
<$set name="myvar" filter="[tag<currentTiddler>]" value=<<currentTiddler>> emptyValue="none">
...
</$set>

Note that the same result can also be achieved with the <$vars> widget, using "inline filter" syntax
combined with the "then" and "else" filter operators, like this:
<$vars myvar={{{ [tag<currentTiddler>then<currentTiddler>else[none]] }}}
...
</$vars>

The main difference here is that the <$set> syntax was created first.  "inline filter" syntax,
and also the "then" and "else" filter operators were added to the TWCore much later.

I hope this explanation hasn't confused you, but simply given you more alternatives
that enhance your TW coding efforts!

enjoy,
-e

Reply all
Reply to author
Forward
0 new messages