Filter help

121 views
Skip to first unread message

Mat

unread,
Feb 21, 2021, 4:47:35 AM2/21/21
to TiddlyWiki
Need some filter help. Pseudocode:

<$vars value={{foo!!value}}>
filter=Among all tiddlers with an id field, if there is no tiddler with id:<value> then do X but if there is a tiddler with id:<value> then do nothing
</$vars>

I assume it is some kind of then ... else construct but I can't quite materialize it and I'm getting confused by how I loose the tiddler titles if I look at their field values. Maybe I need something with the subfilter operator but I'm not sure how... ?

Thank you.

<:-)

Álvaro

unread,
Feb 21, 2021, 8:37:30 AM2/21/21
to TiddlyWiki
Have you tried with contains operator?

In direct filter transclusion you can use something like that
{{{ [all[current]!contains:id<value>then[I have to do X]else[] }}}

Then you can use the filter in a listwidget and use the variable created by the listwidget.

Mat

unread,
Feb 21, 2021, 9:10:56 AM2/21/21
to TiddlyWiki
I appreciate your help but the it is only if no tiddler at all has the id:<value> that something should happen.
Because I take it you mean that your filtered transclusion should be used like so:

<$list filter="[has[id]]">
{{{ [all[current]!contains:id<value> ... ] }}}
</$list>

...but then this will show all the tids with an id field that has another value than <value>
Or do I misunderstand something?

<:-)

Mark S.

unread,
Feb 21, 2021, 10:11:35 AM2/21/21
to TiddlyWiki
Try 

[id<id>then[yes]else[no]compare:string:eq[no]]

Álvaro

unread,
Feb 21, 2021, 12:04:55 PM2/21/21
to TiddlyWiki
Agggh! I wrote "all[current]" but I wanted to write "all[tiddlers]"

Now i put a more simple example which works in tiddlywikiDOTcom , there are 6 tiddler with tag "HelloThere", then filter return 6 times "TRUE" but It was trimmed with (undocumented) unique operator.

{{{ [all[tiddlers]contains:tags[HelloThere]then[TRUE]unique[]] }}}

If change the field tags to tagss the output of filter is empty.

Now you can put your action inside of a listwidget.

<$list filter="[all[tiddlers]contains:id<value>then[TRUE]unique[]]" >
Do X
</$list>

Álvaro

unread,
Feb 21, 2021, 12:15:08 PM2/21/21
to TiddlyWiki
I think I do other typo

If I don't missunderstand something

<$list filter="[all[tiddlers]!contains:id<value>then[TRUE]unique[]]" >

Mat

unread,
Feb 21, 2021, 5:21:25 PM2/21/21
to TiddlyWiki
Mark and Alvaro, your help is much appreciated, and you gave the clues needed to make it work.
Thank you!
<:-)

Álvaro

unread,
Feb 22, 2021, 12:39:51 PM2/22/21
to TiddlyWiki
I have remembered that is possible make it shorter because you don't need to know the output, you just need know if there is only one at least. The then operator is unnecesary but we need change the last operator in the Filter Run. We can do someting like this

{{{ [all[tiddlers]contains:tags[HelloThere]limit[1]] }}}

Mat

unread,
Feb 22, 2021, 12:54:58 PM2/22/21
to TiddlyWiki
Thanks Alvaro. I'm happy to say things worked out.
<:-)
Reply all
Reply to author
Forward
0 new messages