Displaying the caption instead of title in TW 5.2.1 using the new cascade filters

CamelCase titles are useful for linking among other things, but it’s not pretty. Thanks to the new cascade filters, it is now very easy to display a “pretty text” instead of the title !

In a tiddler tagged with $:/tags/ViewTemplateTitleFilter and the field list-before set to $:/config/ViewTemplateTitleFilters/default :

[<currentTiddler>has[caption]then[$:/ui/ViewTemplate/title/useCaption]]

And in the tiddler $:/ui/ViewTemplate/title/useCaption :

\whitespace trim
<h2 class="tc-title">
<$view field="caption"></$view>
</h2>

That’s it !

Try it

5 Likes

Great stuff @telumire

It should be possible to make the filter only kick in for tiddlers that have a caption field like this:

[<currentTiddler>has[caption]then[$:/ui/ViewTemplate/title/useCaption]]

The slight advantage is that the default template would still be used as expected, and so any overrides of that template would be respected.

2 Likes

I didn’t think about that, thanks !

Edited the wiki post to include @jermonlene’s suggestion instead of the original [[$:/ui/ViewTemplate/title/useCaption]]. :slight_smile:

2 Likes

I’d like to update this thread and solutiuon as a result of my thread on field values and character formatting. After almost three weeks, I managed to get my head around suggestions made by @Springer (Field values and character formatting - #30 by Springer) and @Alvaro (Field values and character formatting - #31 by Alvaro). I’ve modified the .json file replacing $view with $transclude, to enable character formatting, and also updated the file to include the change suggested by @jeremyruston.

I’m not quite sure how to adjust the solution so I’m just including the .json file here with a slightly modified file name. I hope I’ve done this correctly.

Caption_instead_of_title_with_character_formatting.json (594 Bytes)

Note that I used the view widget and not the transclude widget for the sole reason to stay consistent with the default title behavior (see $:/core/ui/ViewTemplate/title/default), but I like your approach more ! I will update my post with your solution, thanks :slight_smile:

I also updated my version to include Jeremy’s more elegant filter

1 Like

Both approaches seem valid… the credit should really go to @Springer and @Alvaro - I just did a bit of typing!

2 Likes

A post was split to a new topic: How to use caption instead of title in the TOC, Sidebar All and Sidebar Recent