Optimal TOC use for multiple topics?

@Justin_H many variations like this and in a similar theme have being tackled by a lot of people already, including myself, so searching here in relation to TOC macros should bare fruit. Some notes;

  • The TOC macros have being provide for a Purpose, primarily building tag based contents. However it is quite easy to build your own with one or two macros one that iterates the top level, then calls its self for each of those below. Often called recusive, or tree walking which are other keywords.
  • Also remember here you could have two tags but with the same caption name eg; Characters.
  • You could also invoke two TOC macros one with stories as the root tiddler, and another with characters as the root tiddler. The current toc macros have loop protection.

However keep in mind you can have more than one TOC with its own root tiddlers and when you have items that are the member of two groups it is not uncommon to be tagged with two tiddlers.

I may return with more but this should get you started.

I think that is why I found transitioning to purely using tags to work to some degree with what I aimed for.

Unfortunately when it comes to using the dropdowns for tags, the tiddlers aren’t organized in a hieretical structure, just in a loose network style structure, which is managable for smaller to medium sized TW, but the more tiddlers you have, the more this system can become a bit… time consuming to scroll through.

I admit, a way to resolve this would be to have a search like function that lets you choose specific tag combinations and show the resulting tiddlers, but I just never attempted such a thing.

Or possibly changing the template used to render tags. I wonder if you could apply the toc macro to the tags, so when clicked, they build a toc for each. that could prove fruitful, hm… :thinking: I may experiment with that in the future.

Well, while I can in fact do that, I can also simply tag characters with “Contents” and list it along with the two other stories, and have the character tagged tiddlers show under all three, but not in a structured order, moreso how that would if they were grouped using the tags tab of the more sidebar, but in a different design. A two level at most structure, that is.

My goal is to have something that is self structuring, but organized so that you don’t end up with too large of a selection of tiddlers, while avoiding redundancy where possible.

I believe having multiple toc macros would lead to a bit more to navigate through than other alternatives, but I could be missing something :thinking:

True, and I do use this, even with custom caption fieds, like “toc-caption” for ones just for the toc, and the normal caption can be something else.

However, this does still leave me with the predicament that if I want to see all the tiddlers that are tagged as characters, then having these, as I call them, section tiddlers (ie characters from x, characters from y, both with a toc-caption of ‘characters’) they aren’t listed together under characters unless also tagged characters.

The reason I’d like to have characters there stems from how I plan to use tags as dynamically as possible. for instance, on top of documenting characters I have made, also being able to tag characters from media franchises I am studying would also help, such as tv shows, videogames, books, etc.

for instance, John Doe from The Tower and John Wick from John Wick’s franchise are both characters.

My thoughts are making a filter to use in the sort parameter, something like “all tiddlers tagged contents, what tags do they have, and what those tags are tagging, if what they are tagging is tagged with a tiddler tagged contents.”

Getting that into a filter is… tricky.

The idea of making a custom toc macro for it does sound appealing, but I would want to aim for some way to make it useful in more than one specific way, I’m just not sure how yet.

edit: unfortunately, I have to head to sleep, so I apologize if my answers are delayed by a few hours. I will be returning to this when I wake up though, finding a suitable solution to this would be fantastic.

Edit2: adding this more as a quick n2s, toc that lists all tagged, removes duplicates except from the end most tree node. I think that is possible, I will need to try it tomorrow.

1 Like

I would use the completely rewritten TOC described at: TOC-macros Rewritten (+ a lot of new fuctionality) - Part 2

Then I would use a structure similar to this one

toc-for-multiple-topics.json (1.8 KB) and import it to the preview edition: https://tiddlywiki5-git-fork-pmario-toc-v53x-10443d-jermolenes-projects.vercel.app/

to get this:

With the new TOC macros there will be many other ways to structure a TOC based on tags, fields and a mixture thereof.

The tiddlers attached here will be part of the preview soon, once it is built by the Vercel bot.

have fun!
Mario

1 Like

I have my toc look like the toc that I would provide if I was publishing it. Therefore I would separate characters elsewhere, still in the toc but not under the writing.

I then use links in my writing to the actual characters. Then in the view template for a character I provide a list of chapters (with links) where that person is referenced in my writing. Now my writing and characters are completely cross referenced. I do the same for settings and scenes.

1 Like

This is really cool. Its taken me a second to figure out how this is setup but that might be exactly what I am looking for.

The section tiddlers, like TowerCharacters, listing the character tiddlers but not needing to tag those tiddlers means I can stick to my intended organization, and even down the like I could create a section tiddler FOR section tiddlers that then lists each of them :thinking:

I like that a lot, I’m going to mark it as the solution, and if I find any issues I’ll return here with my findings.

Ah, I imagine when I publish my works they will look drastically different, but my toc layout is meant strictly for me. Maybe down the line I would seperate it from the other topics and use it as a standalone wiki but for the time being, keeping all my things in one system would be best for my work flow, since much of what I study and work on tends to connect with eachother.

Edit:

I’m not actually sure at all how to use this new TOC macro. it seems like using the parentField parameter just removes the usage of the tag parameter entirely.

I was under the impression that if I had a TOC that used the tag Contents, it would list all the tiddlers tagged contents as the first level, and the sub-levels would then list as normal, except if they had the field set with the parentField, where they would then list a custom set of tiddlers under its node.

ie

Contents
  The Tower (tagged "Contents")
    Characters from The Tower (tagged "Section Tiddler" "The Tower")
      list-filter: "[tag[The Tower]tag[Character]]"
        John Doe
    John Doe (tagged "The Tower" "Character" ; not shown in the list except under "Characters from The Tower")

  Character (tagged "Contents")
    John Doe

Would you be able to provide a bit of insight on how the new TOC works, @pmario ?

Okay! I have found the method that works out best for what I’d like to do, and it does use the new rewritten TOC macro, however, it does not use the parentFilter parameter. (though this is a neat feature.)

I had to do a bit of re-re-rereading of the actual TTW thread “TOC-macros Rewritten (+ a lot of new fuctionality) - Part 2” and the github thread but I managed to figure out how I could do what I wanted to do.

By creating a tiddler titled “$:/…/Contents” that uses a toc that looks for tiddlers tagged “Contents” and utilize the toc-filter parameter, I can set “The Tower” to have a toc-filter of [tag[The Tower]tag[Section Tiddler]] to only show tiddlers that have both of those tags.

Next, each section tiddler, lets say one titled “Characters from The Tower” should now have a toc-filter of [tag[The Tower]tag[Character]] with a toc-caption of “Characters” will now list all the characters that are tagged as “The Tower” & “Character” then Bingo!

I appreciate everyone’s help, and this TOC macro 2.0 has some really cool features baked in that I can’t wait to experiment with more.

If I’m being honest, I didn’t really expect to find a way to achieve this, I thought I was hoping for something that would just be technically not possible without some major tradeoff, and I am happy to be proven wrong by the brilliance of the community. :grinning_face_with_smiling_eyes:

1 Like

Yes, the documentation is still missing. I also have to find out, how to use the different features.

That’s why the edition contains a lot of somewhat unrelated test- tiddlers, that may only make some sense for me personally. But they can serve as starting ideas for the docs.
– At least I hope so :wink:

1 Like

If I’m being totally honest- my favorite feature is going to be the toc-filter parameter.

Just from playing with it a bit, I’ve been able to do things that previously just weren’t possible before, such as sorting journal entries in reverse order of the main toc.

I have noticed that the captionField does not seem to use the caption field in the absense of the new field set, I am unsure if this is just because I copy/pasted the $:/core/macros/toc tiddler to a blank tw or not, but I felt I should mention it here.

I resolved this by adding the following to the tiddler that was creating the toc:

\define toc-caption()
\whitespace trim
<span class="tc-toc-caption tc-tiny-gap-left">
	<$set name="tv-wikilinks" value="no">
		<$transclude field=<<captionField>> >
			<$transclude field="caption">
				<$view field="title"/>
			</$transclude>
		</$transclude>
	</$set>
</span>
\end

Edit: Actually, nevermind, my proposed solution above does not actually work, I was mistaken.

1 Like

I absolutely love the work being done in the new TOC tools, but I’m wondering if it’s overkill for your scenario. Your example showed only a few levels of nesting, and that might well be better done with the static approach I used above. Of course if the levels are dynamic, it’s a different story.

This has a variant of the list-based version I suggested above and a collapsible one that uses DETAILS/SUMMARY tags. With a little more CSS, that could be made to look like the sidebar TOCs. And if you wanted, you could replace the DETAILS/SUMMARY with RevealWidgets, which would allow you to maintain state between tiddler launches.

customTOC2.json (2.0 KB)

That’s a nice simplified alternative. Though, I do admit I get more functionality out of the toc rewrite, this would be useful for older wiki that don’t have the if else… hm. I forgot what they are called. the <%if this%> shortcut syntax. I haven’t really used this much, and typically stick to just normal filter syntax :sweat_smile:

I did add this question to the PR. I’ll have to have a closer look.

Thanks for the feedback

Just to clarify, did you set captionField="caption", I would expect it to fall back to title by definition even if the caption field was given.

@pmario would it be difficult to adda tooltipField for example tooltipField=description would display as the tooltip the content of the description field on hover?, if using the caption they could provide the title as the tooltip field, or tooltiop etc…

  • The link widget (now) and Button widget (for a while) have the tooltip parameter, this can be a way to introduce other information, especlialy if its transcluded.

I did not, I use toc-caption as the captionField parameter value, which if i understand correctly, should fallback first to the caption field if toc-caption isn’t present or has text, and if caption is also not present, should finally fallback to the title field.

Also I agree that a tooltip option could be pretty interesting, as if you could set it to display the title of the node while using caption ( or a caption alternative via captionField ) would be nice, though- I would almost lean more towards a tooltip template, like button templates for the tabs macro, but I don’t want to ask too much of mario, these improvements alone are monumentally useful, imo.

I will check the “caption” field handling again. There is a known issue with the current TOC. If a caption field is defined, but it is empty, the toc will show an empty element. I wanted to fix that, but the request was rejected.

The rewritten toc has the same behaviour. I’ll have a closer look.

There is already some tooltip handling in the code. I think it’s a left-over from debugging. Since the “chevrons” still show the folded-state tiddlers :slight_smile:

tooltip template – Interesting.

Tony requested a new tooltipField=description, which I think is also interesting.

There is a new version now: https://tiddlywiki5-git-fork-pmario-toc-v53x-10443d-jermolenes-projects.vercel.app/

  • Users can add a toc-tooltip field to a tiddler, which will be shown on mouse hover
    • Default if no field is set, will show the title.
  • Using captionField:"caption" should work now, if caption is not defined. So it falls back to title
  • Using captionField:"test" should fall back to caption and then to title if no “test” or “caption” fields are defined
  • \procedure toc-defaultItemTemplate() now uses a “filter cascade” to select the different fields to show.
  • There is a data-fieldClass=`field-$(field)$` now, which can be used for styling. The $(field)$ will be replaced with the field-name that is shown. So eg: field-caption or field-title and so on. We need data-fieldClass because field names chan use other character sets than Latin, which is not allowed for the “class” attribute.
3 Likes

I was keen to see a toc-tooltipField setting as I have plenty of tiddlers already with a “description” or “tooltip” field. The idea was to avoid using a bespoke fieldname, because I then have to populate it.

I imagine you should be able to do so by overriding procedure that is adding this.
I haven’t had a chance to see the improvements, but I would expect something like:

\define toc-tooltipField() toc-tooltip

I’ll have a look again.

Edit: There is a tf.toc-getTooltip function now, that you can easily overwrite, when you create a toc.

\function tf.toc-getTooltip() [<currentTiddler>get[toc-tooltip]!is[blank]] :else[<currentTiddler>]

Thanks, still it seems it would be a little more consistent to use the same approach as with your tooltipField (Function) which can also be modified.