TOC or Tree that uses filters instead of tags?

Something I think would be really helpful is the ability to pass filter notation to the tree macro or the toc macros.

Something like <<tree filter:"[creator[JohnDoe]]">> (or similar but using the toc macros) which would create a tree of all tiddlers made by JohnDoe, so that you can still follow the same title format as the core tiddlers which won’t break things like custom config tiddlers, and not need to worry about tagging them, and for some tiddlers finding a different method to find them since you can’t tag them (journal config tiddlers for example)

How could the core tree (or toc) macro be modified to use this over requiring a tag?

A filter for just “creator” wouldn’t construct a tree. But I can imagine a filter that constructs virtual titles dynamically:

"[{!!genre}] [{!!year}] [{!!creator}] +[join[/]]"

So this would create an internal virtual “title” like:

Youth/2000/JK Rowling
Youth/2000/Phillip Pullman

and a resulting tree like

 Youth --
      2000 --
           JK Rowling
           Phillip Pullman

I’ve made a version of tree for myself that uses a separate field to use as the mapping. So I think this might be doable.

That would be really cool

I was thinking that the tree macro specifically would have just listed all tiddlers made by JohnDoe, and excluded others, so instead of

$:/core/ui/A1 (Created by JohnDoe)
  $:/core/ui/A2

$:/core/ui/B1
$:/core/ui/C1
  $:/core/ui/C2 (Created By JohnDoe)

$:/config/value/D1 (Created By JohnDoe)

It’d end up as

$:/
core/ui/
A1 (Created by JohnDoe)
  A2
C2 (Created By JohnDoe)

config/value/D1 (Created By JohnDoe)

But, yea thinking about it this probably wouldn’t work :sweat_smile:

Edit: Would there be a way for something to behave like these two segments though?
Or is it simply not possible?

Putting in a filter should be possible. But you probably need to re-think what you really want. A1, A2, and B1 are all at the same level - siblings. So the output would be simply A1. If there’s some connection you want to between the siblings, you need to specify how that would work.

Ah, yea your right, I didn’t really type that out correctly to what I meant, I was a bit half asleep :sweat_smile:

I think a closer representation would be something more along the lines of

$:/core/ui/A1 (Created by JohnDoe)
$:/core/ui/A1/A2
$:/core/ui/A1/A3
$:/core/ui/B1
$:/core/ui/C1
$:/core/ui/C1/C2 (Created By JohnDoe)
$:/config/value/D1 (Created By JohnDoe)

Hello There (Created By JohnDoe)

which would list out as

$:/
  core/
  ui/
    A1/
      A2
      A3
    C1/
      C2
  config/
    value/
      D1

Hello There

my goal would be using the filter [creator[JohnDoe]] that then separates them by / and turns them into dropdowns that appear like the tree macro renders them, listing it’s children as well

unfortunately I don’t know how the tree macro is turning what looks like <ol> elements into dropdowns, and showing singular tiddlers with the file icon

I don’t really know if that helps or not. My end goal is a tree of tiddlers that automatically lists new tiddlers made by a specific person, or even repurposed for other sorting, like by created

You can try this. Import this into your tw. At the top of the tiddler where you want to use the macro put

\import [[FilteredTree]]

Now in your macro call, you can put filter: "[creator[JohnDoe]]" or filter="[creator[JohnDoe]]" (if called with macrocall widget) .

filtered-tree.json (2.7 KB)

2 Likes

That’s amazing, honestly. I’ll likely try to remove the (0) portion through tinkering since it seems to break here, but this is seriously cool, thank you!

How exactly does this work? I can tell from reading it it’s replacing portions of the tree macro, but the part I couldn’t figure out is how it uses a filter instead? Ah, I was looking at the wrong tiddler… please excuse that :sweat_smile:

Oops. Typo. This should fix it. Knock, knock.

filtered-tree2.json (221 Bytes)

Seems to only contain a tiddler with the filter [creator[JohnDoe]], was that intended?

Try again.
filtered-tree-1415.json (2.7 KB)

2 Likes

I can confirm this is working as intended haha
Thank you for making this, @Mark_S, this will help me better keep track of my tiddlers, and will be fun to learn from :grinning_face_with_smiling_eyes:

1 Like