TOC to only a certain level?

I know you can do this with lists and filters but I’m curious if you can use a standard TOC macro to only go to x levels deep.

Example for illustration. Given related tiddlers with titles like:
zoo
|- reptiles
|—snakes
|-----cobra
|-----rattlesnake

I’d want to only return only:
zoo
|- reptiles
|—snakes

Thanks,
Scott

At the moment the TOC doesn’t have a “recursion-counter”. We would need to add this functionality to the TOC macros.


I have to say, I’m a fan of “full information” … So I don’t like “hidden information”. I think, if information is needed to be hidden, there should be at least a “visual clue” that there is “hidden info” …

So even if the author of a document wants to limit the depth, it may not be right thing to do for every user. So I think users should be aware, that there is more to explore. …

1 Like

Something I’ve wondered about before is an extended version of the TOC macro(s) that uses a cascade to choose the template to use to display each item. If the cascade returns an empty result then it would hide that item and all its children. One of the variables provided to the cascade would be the current heading level. I think that would accomplish what you need.

On a related note, and I hope it’s not a dumb question, how do I get the top level ‘zoo’ to show in a toc at the top level?

For example on tiddlywiki.com;

<$macrocall $name="toc-tabbed-external-nav" tag="ActionWidgets"/>

Shows everything in the hierarchy except the top level ‘ActionWidgets’ tiddler. Is it possible to show it too?

Best
Watt

Jeremy,

I have thought about this for some time and believe it may be as simple as allowing any child node to be able to provide a list field or filter that overrides the way its children are listed.

The difficulty I have had proposing changes, is the complexity of the current toc macros and perhaps a need for a code refresh, or a new set of toc macros.

For example if the standard toc, before recursively processing the children (tiddlers tagged with the current tiddler), it looked for a “named field” and used this to determine the list of children (if present), it would for example allow the children to be sorted a particular way, list only the children or the current tiddler and return to continue the toc from the level before.

As you suggest it would be even better if a cascade was available such that if;

  • A TOC macro Looked to see if the current item provides an alternative filter for its children to be listed (Including the null case) that is the node forces/overrides the method to determine/list its children.
  • look to see if a condition existed and used an alternate filter
    • Ideally in keeping with your idea of the cascade this would be a cascade either;
      • found in one or more nodes or
      • applying to all nodes.

To state it clearly

  • Allow the TOC to be given a tag used to indicate a cascade that determines the nodes to be listed. One or more of these could look for a custom field in a node to use. Default to the current behaviour.
  • Allow the TOC to be given a tag used to indicate a cascade on how to “render each node or link” One or more cascade items could look for a custom field in a node to use. Default to the current behaviour.

This approach would allow almost infinite customisation of the toc.
eg

  • List the subtiddlers below a plugin when a plugin is encountered in the toc
  • List subtiddler titles like the tree macro using the “/” delimiter.
  • Allow a specific node to dictate the filter that defines its children and the template to display/list itself or its children.
  • Such a reworked toc should make available a variable such as depth that a filter may used to limit the depth of the TOC - see OT

Regards
Tones