For your first objective:
In the TOC macros, the “name of the entry” is rendered by a small macro named “toc-caption()”, which has the following default definition:
\define toc-caption()
\whitespace trim
<span class="tc-toc-caption tc-tiny-gap-left">
<$set name="tv-wikilinks" value="no">
<$transclude field="caption">
<$view field="title"/>
</$transclude>
</$set>
</span>
\end
What this does is: “If the current tiddler has a caption field then render it. If there is no caption field in the current tiddler, then show that tiddler’s title”
To customize this output:
Within the tiddler you are using to display your TOC, you can re-define the toc-caption() macro to change what it will display. Thus, for your objective – " which field will be presented depends on the value of a specific tiddler" – you could put the following at the top of your TOC display tiddler:
\define toc-caption()
\whitespace trim
<span class="tc-toc-caption tc-tiny-gap-left">
<$set name="tv-wikilinks" value="no">
<$transclude field={{MyTOCConfig}}>
<$transclude field="caption">
<$view field="title"/>
</$transclude>
</$transclude>
</$set>
</span>
\end
<div class="tc-table-of-contents"><<toc-tabbed-internal-nav "TableOfContents">></div>
Note how I’ve added this line: <$transclude field={{MyTOCConfig}}> (and it’s matching </$transclude>).
What this does is attempt to display a field from the current tiddler, where the name of that field is stored in the text field of MyTOCConfig. If that field doesn’t exist for the current tiddler, it falls back to using the default “use the caption or title” handling.
enjoy,
-e