Filter to show caption field if it exists

101 views
Skip to first unread message

Jon

unread,
Jan 26, 2021, 9:42:30 AM1/26/21
to TiddlyWiki
Hi,

Matt kindly provided this to give a filtered list of tiddlers, the contents of which can be viewed on hover.

<$list filter=[tag[triangle]]>
<div class="hover-to-show">
  <$link/><br>
  <span class="hover-to-show-inner">
    <$transclude mode=block/>
  </span>
</div>
</$list>

How can I adapt it to show the caption field of a tiddler if it exists but the title field if it doesn't and still have the hover and link working?

Thanks
Jon


Mark S.

unread,
Jan 26, 2021, 12:23:26 PM1/26/21
to TiddlyWiki
Try:


<$list filter=[tag[triangle]]>
<div class="hover-to-show">
    <$list filter="[all[current]has[caption]get[caption]] :else[<currentTiddler>]" variable=name >
     <$link><<name>></$link><br/> 
       </$list> 

Jon

unread,
Jan 26, 2021, 3:51:05 PM1/26/21
to TiddlyWiki
Perfect! Thanks a lot Mark.

TW Tones

unread,
Jan 26, 2021, 6:47:38 PM1/26/21
to TiddlyWiki
Jon,

Mark refactrored you code as requested but a shorter for is if the cauurrent tiddler is valid use this;

{{{ [all[current]get[caption]] ~[<currentTiddler>] }}}

Or for plain text

<$text text={{{ [all[current]get[caption]] ~[<currentTiddler>] }}}/>

Regards
Tones

Jon

unread,
Jan 27, 2021, 2:11:01 AM1/27/21
to TiddlyWiki
Thanks for the alternatives, Tones.

Regards
Jon

Reply all
Reply to author
Forward
0 new messages