Semi-Expandable Table of Contents?

72 views
Skip to first unread message

retro_future

unread,
Sep 2, 2018, 7:27:50 PM9/2/18
to TiddlyWiki
So, I have a tagged setup like this:

Main Topic
- Sub-topic 1
-- ST Heading
---- entry 1
---- entry 2
---- entry 3
---- entry 4
-- ST Heading
---- reference a
-- ST Heading
---- reference b
---- reference c

The "main topic" tiddler's body is currently just a simple <<toc>> macro, and in general, this works great. It's also a sidebar tab, so I usually will have that open and click on a ST Heading then "create new tiddler here" when I want to add a new entry. (This is important!)

However, I'm adding about three new entries to one of the Sub-Topic Headings every week so that particular section of the toc will be extremely long eventually. What I want is to have a table of contents that looks like this: 

Main Topic
- Sub-topic 1
-> ST Heading
-- ST Heading
---- reference a
-- ST Heading
---- reference b
---- reference c

So that only the sub-topic with the entries is expandable (& collapsed by default), and I can continue to click on it and the other sub-topic headings directly.

toc-expandable doesn't work for me because it makes everything expandable and that is an impediment to the "click on sub-topic heading, make new tiddler here" workflow.

Any thoughts or suggestions on how to do this?

TonyM

unread,
Sep 2, 2018, 8:46:55 PM9/2/18
to TiddlyWiki
Retro,

If you copy follow the existing table of contents macro you could make your own and insert code to detect a tag or field in any tiddler, and in your case place this in the "ST Heading" tiddler which instead calls the expandable macro.
 
$:/core/macros/toc

If I can I will try and build it but an idea would be to test the "root tag" tiddler for a toc-type field and use this to determine which toc method to use (Expandable or not), then for every tiddler in the tree look for the toc field and redirect the call according to this field.

Actually I will definitely build this solution, if not right away, as I see it forming a useful code pattern for a number of smart tools.

Regards
Tony
Reply all
Reply to author
Forward
0 new messages