can you use af filter to hide or sow text (with lists)

75 views
Skip to first unread message

HC Haase

unread,
Oct 9, 2018, 6:11:06 AM10/9/18
to TiddlyWiki

Goal:
To have a filtered list with a text/header that only appear when there is something in the list e.g.

tagged with current tiddler
 * x
 * y

and if there is no tiddler tagged with the current tiddler the "tagged with current tiddler" text will disappear.

I have looked at the view widget, but it only shows a field of a tiddler and I cant quite figure out, if the reveal widget can take a list argument.

thanks

Jed Carty

unread,
Oct 9, 2018, 6:50:26 AM10/9/18
to TiddlyWiki
You can use the list widget like a reveal widget. Here is a quick example:

<$list filter='[tag<currentTiddler>limit[1]]' emptyMessage="No tagged tiddlers" variable=null>
There are <$count filter='[tag<currentTiddler>]'/> tiddlers listed.
<br>
<$list filter='[tag<currentTiddler>]'>
* <<currentTiddler>><br>
</$list>


</$list>

The emptyMessage part is optional and is displayed when there is nothing in the list.

You can replace the tag<currentTiddler> with whatever filter you want, just be sure to have the limit[1] part on the outer list.

HC Haase

unread,
Oct 10, 2018, 6:04:37 AM10/10/18
to TiddlyWiki
Thanks, that worked!

I have modified the code a bit an made a toc-snippet to insert in my overview/toc tiddlers. here it is for anyone interested.
it shows a tagged list and a linking to list with a header text, but only if the lists are populated. I find this useful, because I don't use the info button much, but if there is a backlink (reference) to the tiddler I see it up front and it gives me a better feel with the structure in my wiki.

<$list filter='[tag<currentTiddler>limit[1]]'  variable=null>
Tagged with //<
<currentTiddler>>// (<$count filter='[tag<currentTiddler>]'/>)
<br>
</$list>
<
<toc-selective-expandable  $(currentTiddler)$ "sort[title]">>

<$list filter='[all[current]backlinks[]limit[1]]' variable=null>
Links to //<
<currentTiddler>>// (<$count filter='[all[current]backlinks[]]'/>)
<br>
</$list>
<
<list-links filter:"[all[current]backlinks[]]" >>

My only concern is if it will be memory intensive (e.g. on android).
$__tags_TextEditor_Snippet_TOC-current tiddler.json

Jed Carty

unread,
Oct 10, 2018, 6:09:23 AM10/10/18
to TiddlyWiki
If I remember correctly the backlinks filter operator is pretty efficient with cacheing so I don't expect this to give you trouble.

Mohammad

unread,
Oct 10, 2018, 8:41:19 AM10/10/18
to TiddlyWiki
Does this like work for you

<<toc-selective-expandable  $(currentTiddler)$ "sort[title]">>

 Is it correct to use $(currentTiddler)$ alone inside a tiddler?
Reply all
Reply to author
Forward
0 new messages