toc-selective-expandable with more than one search criteria

380 views
Skip to first unread message

Martin Petersen

unread,
Dec 4, 2018, 11:38:39 AM12/4/18
to TiddlyWiki
Good evening, I am just starting to explore this wonderful piece of ingenuity so bear with me when I ask a silly question:

When I want to make a table of contents Tiddlly with the help of the toc-selective-expandable command I can search for one tag but I fail to combine two or more. Let’s say I have Tiddlys with the tag Company and some of them have Text as another tag and some others have the tag Numbers (but not the tag Text) and I would like to list only those Tiddlys with a combination of the tags Company and Numbers (excluding those with the tag Text). How do I do this and where is this documented?
Thanks for your help.

Mark S.

unread,
Dec 4, 2018, 2:54:10 PM12/4/18
to TiddlyWiki
Everybody loves the TOC macros ... and then immediately wants to change them ! ;-)

Something like this comes up so often, there should probably be a comment in the TOC documentation.

A partial solution is to use the "sort" parameter. You can make a sort parameter perhaps like:

sort:"!tag[Text]"

The problem, if I recall correctly, is that the TOC macro will still create branches, even if the branch has no "leaves". Still, it's a start.

Good luck!
-- Mark

TonyM

unread,
Dec 4, 2018, 6:54:32 PM12/4/18
to TiddlyWiki
Martin,

On tiddlywiki.com for toc selective expandable we see

<div class="tc-table-of-contents">
<
<toc-expandable "Contents">>
</div>

That is it calls the macro toc-expandable

In advanced search Shadows we find this is in 

$:/core/macros/toc


Which on editing we see the definition

\define toc-expandable(tag,sort:"",itemClassFilter:" ",exclude,path)
<$vars tag="""$tag$""" sort="""$sort$""" itemClassFilter="""$itemClassFilter$""" excluded="""$exclude$ -[[$tag$]]""" path="""$path$/$tag$""">
 
<ol class="tc-toc toc-expandable">
   
<$list filter="""[all[shadows+tiddlers]tag[$tag$]!has[draft.of]$sort$] -[[$tag$]] $exclude$""">
     
<$list filter="[all[current]toc-link[no]]" emptyMessage=<<toc-expandable-empty-message>> >
       
<$macrocall $name="toc-unlinked-expandable-body" tag="""$tag$""" sort="""$sort$""" itemClassFilter="""itemClassFilter""" exclude=<<excluded>> path=<<path>> />
      </
$list>
   
</$list>
  </
ol>
</$vars>
\end

If you look in the define line you can see mention of parameter that appear not fully documented. and exclude is simply added to the end of the filter.

Perhaps trying providing your own exclude parameter, perhaps even to include something +[[tag]]

But I ask do you really want a TOC macro here, because the TOC requires each tiddler be tagged with a tiddler higher up in the tree, and eventually the root tiddler, is this still true when you try and exclude one of your tags?

Regards
Tony

Martin Petersen

unread,
Dec 5, 2018, 8:00:04 AM12/5/18
to TiddlyWiki
Tony and Mark, thanks so much for your replies. I think I will have to dive deeper into tagging in TW as it seems to work not as I expected it to do.

Best regards

Martin

bimlas

unread,
Dec 5, 2018, 8:55:47 AM12/5/18
to TiddlyWiki
Martin,

I do not quite understand what you want to achieve: filtering through multiple tags is the point or the table of contents?

If this is the first option, maybe this plugin can help: https://bimlas.gitlab.io/#Filter%20by%20multiple%20tags%20easily%3A%20FilteredTag%20example

I work on other solutions to make tags really useful, but all of them are still in development. For example, type in the search box: "wiki #macro" - it will list the related tags that you can apply for the search. Another way to find tag on the Contents sidebar: Press >> next to the items to "open" it (such as the table of contents), the related tags are listed on the top of the sidebar - I would like to use the `kin` filter (https://bimlas.gitlab.io/demo/tw5/kin-filter.html) on listing, so that only those elements that are in the given context will appear.

Again I signal that these are under development, do not use it in your own wiki.

bimlas

unread,
Dec 6, 2018, 9:41:15 AM12/6/18
to TiddlyWiki
I've accomplished the above-mentioned operation: You can try it out on the https://bimlas.gitlab.io/demo/tw5/kin-filter-toc-demo.html page (scroll to the "View of context - a more sophisticated toc macro powered by kin filter" heading). Remember: still under development!
Reply all
Reply to author
Forward
0 new messages