Prevent state from being saved

Hi there,

I’ve got a TOC as a template at the beginning of every tiddler:

<div class="tc-table-of-contents">
<$macrocall $name=toc-selective-expandable tag={{!!title}}/>
</div>

Is it possible to prevent the state of this special TOC - items (not) collapsed - from being saved?

My own research did not lead to a solutiion …

Jens

The toc-selective-expandable macro uses other macro (toc-linked-expandable-body) that manages this behaviour (open/close), both macros aren’t configurable in this aspect.

You should modify toc-linked-expandable-body changing the reveal widgets and the button widgets that use/change the value of tiddler pointed by <<toc-state>> macro call.

But I don’t recommend it, because the other call of this macro will be expanded by default.

It is better create new macros from a modified copies of toc-selective-expandable and toc-linked-expandable-body (with other names for your macros to don’t overwrite the original). Your special toc-selective-expandable should just a copy of the original but that use a call to your “newtoc-linked-expandable-body

The TWCore toc macros store the opened/closed state of each branch in system tiddlers that start with a prefix of $:/state/toc. By default, these state tiddlers are retained when you save your TiddlyWiki file. You can prevent these tiddlers from being saved by doing the following:

  1. Create a tiddler (e.g., “ResetTOCStates”), tagged with $:/tags/Macro
  2. In the body text of this tiddler, enter
    \define publishFilter() -[prefix[$:/state/toc]]

The publishFilter macro is used in $:/core/save/all to add or remove selected tiddlers from the saveTiddlerFilter definition that controls which tiddlers are to be saved in the file when the "Save changes" button is pressed.

By specifying “-[prefix[$:/state/toc]]” in your publishFilter macro, you are telling the TWCore to NOT save those tiddlers in the file. Thus, when you save-and-reload your file, all the TOCs in your TiddlyWiki are automatically returned to their initial default state.

enjoy,
-e

3 Likes

I am sure @EricShulman solution is effective, but may I ask why you want this?

  • What if you had a reset button that deletes all “prefix[$:/state/toc]” tiddlers?
  • There may be something behind your request that has a different answer.

Ouch! I don’t know if I understood corretly your question.

I’ve got an extensive TiddlyWiki where I keep my (job-related) researches (legal stuff), sorted by nested tags. As I wrote above, every tiddler gets a TOC build of its title as a tag and downwards. If I look something up, I’m using the TOC, not a search, often adding new points. Not collapsed TOCs take too much space and make the view unclear.
Not saving the state lets me always start from the beginnig and I don’t need to take care of collapsing the TOC when saving.

2 Likes