Nested filters for large report

184 views
Skip to first unread message

Ivan Aparicio

unread,
Aug 9, 2018, 11:41:22 AM8/9/18
to TiddlyWiki
Hi All,

I'm trying to write a filter that will put together a report with headings based on tags. As an example:
  • 2 types of tiddler: Fruit tiddlers and review tiddlers.
  • Review tiddlers are tagged with the name of the fruit (say Apple) and the variety (say Fuji, Granny Smith)
I would like a report tiddler for each fruit that will list reviews under a heading for each variety.

So for example:

=Apple=
==Fuji==
Great! Loved the taste, and crunchiness!
Very good; nice peel.
==Granny Smith==
Only liked the colour, so will not be buying again
Good size for the price!
Good value, but do not use for juice!

Is this even possible? Has someone done something similar?

Thanks for reading!

Diego Mesa

unread,
Aug 9, 2018, 12:08:26 PM8/9/18
to TiddlyWiki
Hey Ivan, 

Sure! The code for a simple version of the "Report" tiddler:

<$list filter="[tag[Fruit]]" variable="currentFruit">

    ! <
<currentFruit>>

    <$list filter="[tag
<currentFruit>tags[]] -[<currentFruit>]" variable="currentVariety">

        !! <
<currentVariety>>

        <$list filter="[tag
<currentFruit>tag<currentVariety>]" variable="currentReview">

            !!! <
<currentReview>>

            <$transclude tiddler=<
<currentReview>>/>

        </$list>

    </$list>

</$list>


You can test this on Tiddlywiki.com if you import the following testing tiddlers (attached as a JSON file)
fruits-review-test.json

Mark S.

unread,
Aug 9, 2018, 12:11:48 PM8/9/18
to TiddlyWiki
It looks like you're using markdown. AFAIK, you can't mix markdown with TW's dynamic widget abilities. But if it's the effect you wanted, and if your data is literally only two levels deep, then it's pretty straight-forward:

<$list filter="[tag[Fruits]]" variable="FruitGroup">
<h1> <<FruitGroup>> </h1>
<$list filter="[tag
<FruitGroup>]" variable="Fruit">
<h2> <<Fruit>> </h2>

<$transclude tiddler=<
<Fruit>>/>

</$list>
</$list>

HTH
-- Mark

Ivan Aparicio

unread,
Aug 10, 2018, 11:20:59 AM8/10/18
to TiddlyWiki
Thanks guys!

I used bits from each answer to start building the real application (I thought a simple example using fruit would be easier to answer): A professional development log based on projects, skills and achievements!

In my application, projects = fruits, achievements = reviews and skills = fruit varieties (weird I know). I've attached my TW file as it is, and it should make sense - please let me know if it doesn't.

I am trying to show the skills (tags) for each achievement, but for some reason my pr:Project 1 tiddler is showing all of the skills tags for all achievements. Do you guys know why? I've attached the TW.

Thanks!
log.html
Reply all
Reply to author
Forward
0 new messages