Filter advanced search

76 views
Skip to first unread message

Bob Flandard

unread,
Aug 9, 2020, 8:04:13 AM8/9/20
to TiddlyWiki
Hello,

I'm trying and failing to write a filter expression that lists all tiddlers that are tagged "some name" (call this list of tiddlers resultA) and then extend that list to include all tiddlers that are tagged with the names in resultA. For the general case this would continue recursively until no new tiddlers were added to the list.

Any ideas?

Thanks, Bob

Mark S.

unread,
Aug 9, 2020, 9:29:27 AM8/9/20
to TiddlyWiki
To do this in one step, like you want, you would probably need something like the kin filter operator:

Eric Shulman

unread,
Aug 9, 2020, 11:00:49 AM8/9/20
to TiddlyWiki
On Sunday, August 9, 2020 at 5:04:13 AM UTC-7, Bob Flandard wrote:
I'm trying and failing to write a filter expression that lists all tiddlers that are tagged "some name" (call this list of tiddlers resultA) and then extend that list to include all tiddlers that are tagged with the names in resultA. For the general case this would continue recursively until no new tiddlers were added to the list.

I did exactly this function as part of the InsideTW "page navigation" interface.

It does a recursive "walk" of a "tag tree", and generates a flat list of tiddler titles:

\define toc-list(here,max,exclude,level:"1")
<$list filter="""[tag[$here$]] $exclude$ -[[$here$]]""">
   
<$link /><br>
   
<$reveal default="$level$" type="nomatch" text="$max$">
     
<$macrocall $name="toc-list" here=<<currentTiddler>> max="$max$" exclude="""$exclude$ -[[$here$]]""" level={{{ [[$level$]add[1]] }}}/>
   
</$reveal>
</
$list>
\end

Invoke it like this:
<<toc-list "some name">>
where "some name" is the top-level tag for your tree.

Notes:
1) There is also an optional "max" parameter to limit the depth of traversal
2) The "exclude" and "level" parameters are only for internal use by the macro itself
3) The default output just lists each title, one per line.  If you want a bullet list, you could change this line:
<$link /><br>
to this:
<li><$link /></li>
and if you want a numbered list, also wrap the macro invocation within <ol>...</ol>, like this:
<ol><<toc-list "some name">></ol>

enjoy,
-e 

Bob Flandard

unread,
Aug 9, 2020, 11:21:49 AM8/9/20
to TiddlyWiki
Thanks Mark!

That seems to do the trick.

Regards, Bob

Bob Flandard

unread,
Aug 9, 2020, 11:28:59 AM8/9/20
to TiddlyWiki
Thanks Eric!

This also works. I'm impressed that you remember what you did and retrieve data from the large set of macros/functions you've written. I'm guessing you've got to hand some form of searchable database that allows the retrieval of bite-sized data chunks :)

Regards, Bob
Reply all
Reply to author
Forward
0 new messages