[Question] filter start with [all[current]]

88 views
Skip to first unread message

Mohammad Rahmani

unread,
Feb 24, 2021, 1:50:46 AM2/24/21
to tiddl...@googlegroups.com
I have a view template like below

\define FilterTiddler() test-tiddler

<$set name="revealFilters" tiddler=<<FilterTiddler>> field=text emptyValue="[!is[system]]">
<$list filter="[all[current]subfilter<revealFilters>match<currentTiddler>]">
<<currentTiddler>> is selected!!
</$list>
</$set>




This template is used to show a message on a selected tiddler (those filtered through reavealFilters.
Filter shall be able to
1. select only one tiddler e.g myTiddler
2. select tiddlers by tag e.g. [tag[myTag]]
3. select tiddlers by combination of criteria e.g. [tag[foo]] [tag[bar]] [prefix[New]]

My question is: in the above code
1. the subfilter is a selection constructor. Why do we need all[current] in the filter?
2. What do you propose for the last part of the filter run? It seems the match<currentTiddler>  is slow?
3. What simpler solution do you propose?



Best wishes
Mohammad

Mohammad Rahmani

unread,
Feb 24, 2021, 2:32:18 AM2/24/21
to tiddl...@googlegroups.com
It seems this also works:

\define FilterTiddler() test-tiddler

<$set name="revealFilters" tiddler=<<FilterTiddler>> field=text emptyValue="[!is[system]]">
<$list filter="[subfilter<revealFilters>match<currentTiddler>]">

<<currentTiddler>> is selected!!
</$list>
</$set>

Is there any simpler solution?

Best wishes
Mohammad

Saq Imtiaz

unread,
Feb 24, 2021, 2:58:09 AM2/24/21
to TiddlyWiki
Have you tried something like this (without using a set widget)

[all[current]subfilter{tiddler-with-filter}]

where the filter in tiddler-with-filter is something like:

[tag[myTag]]

Mohammad Rahmani

unread,
Feb 24, 2021, 4:16:51 AM2/24/21
to tiddl...@googlegroups.com
Hi Saq,



On Wed, Feb 24, 2021 at 11:28 AM Saq Imtiaz <saq.i...@gmail.com> wrote:
Have you tried something like this (without using a set widget)

[all[current]subfilter{tiddler-with-filter}]

While subfilter is a selection constructor why we need all[current]?

 
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/1d28c359-6134-46c0-9d04-8c26794c3447n%40googlegroups.com.

Saq Imtiaz

unread,
Feb 24, 2021, 4:40:11 AM2/24/21
to TiddlyWiki
You don't need it, but it limits the input to the subfilter to a single tiddler which is much faster than evaluating it for all tiddlers. Furthermore this obviates the need for the match<current> part.

Mohammad Rahmani

unread,
Feb 24, 2021, 5:16:26 AM2/24/21
to tiddl...@googlegroups.com
On Wed, Feb 24, 2021 at 1:10 PM Saq Imtiaz <saq.i...@gmail.com> wrote:
You don't need it, but it limits the input to the subfilter to a single tiddler which is much faster than evaluating it for all tiddlers. Furthermore this obviates the need for the match<current> part.

Thank you! Let's give a try this new solution!

Mohammad Rahmani

unread,
Feb 24, 2021, 5:24:49 AM2/24/21
to tiddl...@googlegroups.com
Hi again Saq!

On Wed, Feb 24, 2021 at 11:28 AM Saq Imtiaz <saq.i...@gmail.com> wrote:
Have you tried something like this (without using a set widget)

[all[current]subfilter{tiddler-with-filter}]

where the filter in tiddler-with-filter is something like:

[tag[myTag]]


Tested above solution works but if I use a tiddler name for example HelloThere when I tested on https://tiddlywiki.com/
I see the output on all tiddlers, Does it mean [all[current]] bypassed here? I think this is because subfilter ignores the input!


 
--

Saq Imtiaz

unread,
Feb 24, 2021, 5:39:17 AM2/24/21
to TiddlyWiki
[all[current]subfilter{tiddler-with-filter}]

works when filter in tiddler-with-filter is something like:

[tag[myTag]]

which tests conditions on its input (i.e. selection modifiers).

However if the filter applied by your subfilter is of the form:
HelloThere (i.e. selection constructor)

It is equivalent to writing [all[current]title[HelloThere]] which will always evaluate to HelloThere and since the filter always has a result your view template will be applied to all tiddlers.

Alternatively if you want to use selection constructors, you could do this though it will be slower:

[all[current]] :intersection[subfilter{tiddler-with-filter}]

or

[subfilter{tiddler-with-filter}contains:title<currentTiddler>]

Mohammad Rahmani

unread,
Feb 24, 2021, 5:43:10 AM2/24/21
to tiddl...@googlegroups.com
Thank you Saq!

Now, I got the point with your detailed explanations!

Much appreciated!

Best wishes
Mohammad


--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages