Exclude Tiddler from TOC Widget

Is there a way to have the table of contents widget exclude a certain tiddler? Also, can I exclude all childless tiddlers?

See: https://tiddlywiki.com/#Table-of-Contents%20Macros

There is an exclude parameter to globally exclude tiddlers. It allows TitleLists or subfilter expressions.

Excluding all childless tiddlers will be tricky. I do have no idea about this one atm.

As @pmario has already noted, the TWCore toc macros accept an exclude parameter, which is a list of tiddler titles and/or filter expressions that result in tiddler titles.

To exclude specific named tiddler titles, you could write:
<<toc tag:"..." exclude:"SomeTitle SomeOtherTitle">>

To exclude all titles that match a filter (for example, “anything with an ignore field”), you could write:
<<toc tag:"..." exclude:"[has[ignore]]">>

Here’s a filter that finds all “childless” tiddlers:
{{{ [all[tiddlers]] :filter[tagging[]count[]match[0]] }}}

To exclude those childless tiddlers from the toc output, you could write:
<<toc tag:"..." exclude:"[all[tiddlers]] :filter[tagging[]count[]match[0]]">>

However… if your toc tree is very large, this exclude filter might be “expensive” to repeatedly invoke for each item in a toc tree.

To address this, you can “pre-compute” the childless tiddlers list, and store it in a variable. Then just reference that variable in the exclude parameter of the toc macro, like this:

<$set name="childless" filter="[all[tiddlers]] :filter[tagging[]count[]match[0]]">
<<toc tag:"..." exclude:"[enlist<childless>]">>
</$set>

enjoy,
-e

3 Likes