Table of Contents sometimes retains last activity

Hello again,

I’m scratching my head here trying to understand something a couple of days:
My ToC on the sidebar under “contents” would launch with the contents of whtever tiddler containing ToC besides the main ToC open.

So for example, we have A B C and D. pretend each letter has a sub topic, so A has A1 and A2, B has B1 and B2 and so on.

Under my contents tab at the sidebar, as long as I have only one ToC, at the side bar, it will look like this:

  • A
  • B
  • C
  • D

If I add ToC to C which contains C1 and C2 with the same code:

<div class="tc-table-of-contents">
<<toc-selective-expandable 'C'>>
</div>

Every time I launch the wiki now, it will show like this:

  • A
  • B
  • C
    • C1
    • C2
  • D

Why is that? This shows up regardless if I open C1 and C2 or not.

I recently added a FAQ page under my main “Start Here” Page, and this page too always shows up under its parent, “Start Here”. I don’t understand why. I tried different browsers and cleared the cache, this doesn’t make sense to me…?

you can find my wiki at The Art of Not Asking How — Tech Voyages and Beyond

1 Like

The TOC macro is saving records of each branch that gets opened(and also then closed). If you expand the Tools branch, there are also some EMACs branches that are also still open by default. To clear these states…

Go to the Advanced Search tiddler, click on the Filter tab, and paste the following in the text box:

[prefix[$:/state/toc/]]

Click on the Trash Can icon next to the text box and click “Delete These Tiddlers”

Once these state tids are gone, the TOC will go back to being fully collapsed.

When using the macro, if you close the branch before saving the saved state should stay until the next time you open it.

1 Like

You can find the state tids yourself, before deleting them, by:

  1. Clicking on the “More” tab in the Sidebar.
  2. Click on the “Explorer” tab.
  3. Scroll down and click on the “state” link.
  4. Click on the “toc” link.

There are all the records of expanded/collapsed branches. They can all be deleted without hurting anything.

Thanks, this explains why this happens, and now that I changed the status to “closed” on the FAQ state tiddler, the FAQ is now closed when I re-launch.

I understand why this is a good idea by design, but it’s not so great when you have a wiki online (like tiddlywiki.com). Do I have to delete the state every time I update? I can do that with what you showed me, but I’m probably going to forget sometimes.

Is there a way to reset it, or turn this feature off?
Or, perhaps a better way to work that I’m not aware of, where people go around using the Contents altogether, since the whole ToC is optional (I’m wondering if I’m missing an obvious workflow?)

Thanks!

I am not realy sure I understand your specific problem, but this background info should help.

If you are on a read only site if you reload, any unsaved tiddlers including those with the prefix “$:/state/” are lost.

When you save a wiki it usually uses the filter in $:/config/SaverFilter which does not as a rule save the tiddlers with the prefix “$:/state/”.

The TOC macros use state tiddlers using the qualify widget

<$qualify name="toc-state" title={{{ [[$:/state/toc]addsuffix<__path__>addsuffix[-]addsuffix<currentTiddler>] }}}>

So the toc-selective-expandable will use the same “qualified state tiddlers” where ever and how often you use it.

  • The macro is defined as;
\define toc-selective-expandable(tag,sort:"",itemClassFilter,exclude,path)
...

And you can see the parameters include path, which is also part of the qualify macro, as a result you can make a unique set of state tiddlers by including a path parameter, eg; in your ‘C’ tiddler.

<div class="tc-table-of-contents">
<$macrocall $name=toc-selective-expandable tag='C' path=<<currentTiddler>> />
</div>
  • I use the macrocall widget so I can easily provide path=<<currentTiddler>>
  • I have not tested it but please do try it.

There are actually 2 different TWCore shadow tiddlers involved in saving:

  • $:/config/SaverFilter - contains filter syntax to define which tiddlers will mark the document as “dirty” (needing saving). This controls when the “save wiki” button will turn red, and if you get a warning when exiting without saving. By default, changes to [prefix[$:/state]] don’t mark the file as “dirty”.

However…

  • $:/core/save/all - defines a macro, saveTiddlerFilter() that controls which tiddlers will actually be saved in the file. Note that -[prefix[$:/state/popup]] is automatically excluded, but [prefix[$:/state]] is included when you save the file.

You can customize the filter used in $:/core/save/all by adding a separate tiddler (any name you like), tagged with $:/tags/Macro, containing a macro named publishFilter() that defines additional filter syntax to be used by $:/core/save/all. So… to prevent the TOC state from being saved:

  1. Create a tiddler (e.g., MyPublishFilter)
  2. Give it a tag of $:/tags/Macro
  3. In the body of the tiddler, write: \define publishFilter() -[prefix[$:/state/toc]]

That’s it. From then on, saving the file will omit the $:/state/toc tiddlers, which effectively closes all open branches of the ToC when you next reload the file.

enjoy,
-e

5 Likes

I am not realy sure I understand your specific problem, but this background info should help.

I work inside my single-version html file to edit tiddlers. To do that, I navigate to the individual tiddlers using my ToC, on the sidebar, under “Contents”. This, as explained very well to me here (and thank you!) means that the wiki retains the state of which tiddlers were open in the ToC.

When I push the wiki to gitlab, the now published wiki retains this status. This means that visitors to the wiki will see different tiddlers open in the ToC to the side, depending on what I was working on. This is something I don’t want, since I want the same experience every time you visit the wiki: the same ToC with everything closed.

This is how it works in tiddlywiki.com: when you visit, the ToC to the side shows everything closed. It will be very messy to see all the tiddlers that were worked on open.

So I’m pretty sure tiddlywiki.com either has a way to “reset” the status (or to bypass it completely) or, whenever someone works on the site, they don’t use the ToC at all but just create tiddlers / work on them by navigating to them in a different method.

This second option is what I meant by asking about a different workflow. I’m wondering if in general people (like you guys, experts of TW the way I see it :slight_smile:) just go around the ToC and have a quicker way of navigating where you want.

Thanks for the explanations! I’m learning boatloads and I love it.

I use the Command Palette plugin almost exclusively these days. I started out with a sidebar ToC in my own wiki, but discovered I was ignoring it in favor of the search bar 99% of the time. Command Palette fills the same role and also gets out of my way when I’m not using it, so I can use the sidebar space for something else or minimize it entirely.

If I were publishing a public-facing wiki, I think I’d probably keep the ToC for guests’ convenience, but otherwise, it’s easier for me to navigate directly to the tiddler I want or use search filters to drill down into a subset of tiddlers. I should say that I work exclusively on desktop, though; I’m not sure if my workflow would work as well on mobile.

Excellent tool! I might use it, for now I’m digging into the search a bit more. I need to learn how to use the filters a bit more conveniently (because then I don’t need to use the mouse to click the different tabs in search) but this is already a good idea in itself.