I am trying to create a ToC with tiddlers showing not the default title or caption fields but the content of an alternative title, that is, a value in the field named “alt-caption”, for example. This is to have the content displayed in multiple languages.
I thought I could use PMario’s tocP plugin to do this but I can’t make it work. It seems to work with custom fields that need to mark parental relationships (if I understood it correctly).
Is there a way how to have multilingual titles in Table of Content?
You can actually do it with the built in toc by creating a local function with the logic needed.
eg \function toc-caption()[<currentTiddler>get[alt-caption]]
To preserve the TWCore default whitespace, CSS and fallback handling, I suggest:
\define toc-caption()
\whitespace trim
<span class="tc-toc-caption tc-tiny-gap-left">
<$set name="tv-wikilinks" value="no">
<$transclude field="alt-caption">
<$transclude field="caption">
<$view field="title"/>
</$transclude>
</$transclude>
</$set>
</span>
\end
notes:
-
tc-toc-caption and tc-tiny-gap-left CSS classes are applied
- embedded wikilink syntax is disabled
- if
alt-caption field exists, render it
- else, if
caption field exists, render it
- else display
title field value.
-e
Thank you, Eric, now it’s much clearer for me.
I have not made it work yet, but I will get there, just need more time to test it all.
Thank you, again!
Albertina