Filter Help: linking second filter to the first to group items by suffix

How can I get the following output linking items with the appropriate group based on the fieldname?

group1 name
item1stuff

group2 name
item2 stuff

This is close but lists all item-x fields under each group. Unknown number of group|item pairs per tid.

<$list filter="[<currentTiddler>fields[]prefix[group]]" variable="thisfield">
<$view field=<<thisfield>>/><br>
<$list filter="[<currentTiddler>fields[]prefix[item]]" variable="thisitem">
<$view field=<<thisitem>>/><br>

</$list>

Try this:

<$list filter="[<currentTiddler>fields[]prefix[group]]" variable="thisgroup">
   <$view field=<<thisgroup>>/><br>
   <$let itemprefix={{{ [[item-]] [<thisgroup>split[-]nth[2]] +[join[]] }}}>
   <$list filter="[<currentTiddler>fields[]prefix<itemprefix>]" variable="thisitem">
      &emsp; <$view field=<<thisitem>>/><br>
   </$list>
   </$let>
</$list>

Notes:

  • Inside the outer $list widget, we construct the desired “item-#” prefix by using a “filtered transclusion” to join together the literal text “item-” and the number for the current group, which we extract from the thisgroup variable using split[-] and nth[2] filter operators.
  • We can then use the constructed prefix in the second $list widget’s filter.
  • I added an &emsp; (a full em-space HTML character) to provide indentation for the item output

enjoy,
-e

1 Like