How to use caption instead of title in the TOC, Sidebar All and Sidebar Recent

In the same scenario, how to display the caption instead of title in the TOC (e.g. $:/core/ui/MoreSideBar/All and $:/core/ui?moreSideBar/Recent)?

2 Likes

Hi Hsins,

The TOC already uses the caption field if a tiddler has one. Eg:

  • Go to tiddlywiki.com HelloThere
  • Edit the tiddler
  • Add a caption field → You’ll see it in the TOC

The Recent Tab uses the timeline-macro, which would need to be changed.

There is no way at the moment that it uses caption instead of title.


More Sidebar All uses the ListItemTemplate which would also need a change.

We don’t let “caption” overwrite every listing.

So what is your usecase?

1 Like

I just saw the demo from TiddlyWiki 舞 — ćŸșç€Žæ–‡ä»¶æ­Łé«”äž­æ–‡ç‰ˆ and wonder for how it be done. It always shows captions instead of titles. That’s not my usecase but thanks for your reply:)

I also want this, so with 5mins of digging,

by look at $:/core/macros/timeline and found it is un-modified, so I read the comment in the code:

<!-- Override one or both of the following two macros with a global or local macro of the same name 
if you need to change how titles are displayed on a timeline -->

\define timeline-title() <$view field="title"/>

I realized there must be a tiddler modify the timeline-title, so I just use Advanced search for it, and found:

http://tw5-zh.tiddlyspot.com/#%24%3A%2Fcore%2Fmacros%2Ftimeline-title

\define title() <$view field="title"/>
\define timeline-title()
<$set name="tv-wikilinks" value="no">
	<$set name="display" tiddler=<<currentTiddler>> field="caption" emptyValue=<<title>>>
		<<display>>
	</$set>
</$set> 
\end

So just drag this tiddler to your wiki, it will works.

2 Likes

Another methjod in 5.3.x is

\function display-title() [all[current]get[caption]else{!!title}]

<<display-title>> <!-- this returns text -->

Or in a link

<$link><<display-title>></$link> <!-- this still links to the tiddler "title" -->

You could create a switch to show caption if available, or turn it off to always show the title.

1 Like

A much more compact way to write this:

\define timeline-title() <$view field=caption><$view field=title/></$view>

By default, the $view widget displays the specified field’s value as plain text. However, if the specified field is blank or doesn’t exist, then the widget’s inner content is rendered. Thus, the above will display the current tiddler’s non-blank caption text with a fallback to the tiddler’s title.

4 Likes