Grouped list of data tiddlers

100 views
Skip to first unread message

Iain

unread,
Feb 18, 2018, 7:46:52 PM2/18/18
to TiddlyWiki
I'm having a bit of trouble building a grouped list of data tiddlers. My data tiddlers are dictionaries (rather than JSON), and have the expected form:

type: type1
field1: value1
field2: value2
...

I want to display a list of tiddlers, grouped by the "type" property. Unfortunately, I can't seem to work the tiddly magic to make it happen. If I take the "type" property out of the dictionary and make it a field of the data tiddlers, there's no problem.

The doc for "each" seems to make it clear that it operates on fields (not indexes/properties).

I messed around with "getindex[type]" because the doc suggests values should be dominantly appended to the output (which ought to produce a list of unique values) but it always seems to include duplicates when I use it. The basic form:

<$list filter="[each[type]]">
  <$list filter="[type{!!type}]">
    <!-- display code here -->
  </$list>
</$list>

works fine when "type" is a field. But I can't work it out when "type" is a property/index - can anyone help?

Cheers, Iain

Jed Carty

unread,
Feb 19, 2018, 3:25:08 AM2/19/18
to TiddlyWiki
Tiddlywiki is built around fields so as you have discovered, it is much easier to build things in tiddlywiki that use fields.

That being said, to do this using indexes you need something like this:

<$list filter='[all[]]' variable=ThisTiddler>
 <$list filter='[
<ThisTiddler>indexes[]prefix[type]suffix[type]]'>
 
<!-- display code here -->
 </$list>
</$list>


There are problems with this approach, like a field called typefootype will also show up.

Stephan Hradek

unread,
Feb 19, 2018, 6:53:17 AM2/19/18
to TiddlyWiki
Better use regexp to find the type

<$list filter='[all[]]' variable=ThisTiddler>
 <$list filter='[
<ThisTiddler>indexes[]regexp[^type$]]'>

  <
<ThisTiddler>>
 </$list>
</$list>

It will solve the issue mentioned.

Iain

unread,
Feb 19, 2018, 9:01:45 PM2/19/18
to TiddlyWiki
Thanks Jed and Stephan. Very helpful.

Cheers, Iain
Reply all
Reply to author
Forward
0 new messages