One "Filter query" inside Many Tiddlers

105 views
Skip to first unread message

Mohamed Amin

unread,
Feb 21, 2021, 6:10:00 AM2/21/21
to TiddlyWiki
Hi all,

Suppose that I've a single "Filter Query" which be used inside a lot of Tiddlers.
Is there a way to save that query inside a "separated tiddler" or "field", so If I need to change/correct it, I can change it from one single location?

For example: a query like:
QUERY="[enlist{$TdlrName$!!elements}each[aliases]get[aliases]] +[enlist-input[]trim[]each:value[]]"

1- used in one Tiddler as =
<$list filter=QUERY >
do something
</$list>

2- and in another Tiddler as =
<$set filter=QUERY variable="var">
Do another thing
</$set>

Also used in many other Tiddlers.

Now, can I implement some thing like the below, so I can put it inside all affected tiddlers?

<$list filter={{!!QueryInsideField}} >
do something
</$list>

Regards

Mohamed Amin

unread,
Feb 21, 2021, 7:10:35 AM2/21/21
to TiddlyWiki
OK, I figured it our, below is how I get it by using a Macro and "wikify" widget:

1- Put the "Query" in side a field (or tiddler) without Quotations 
query=[all[]tag[B]]

2- Create a Macro to prepare the "Transclusion" string:-
\define me()
{{!!query}}
\end

3- Excute the "Transclusion" to get the "final value" :
<$wikify name="ss" text=<<me>> >

4- Use the "final value" inside your filter :
<$list filter=<<ss>> variable="dd" >


\define me()
{{!!query}}
\end

<$wikify name="ss" text=<<me>> >
     <$list filter=<<ss>> variable="dd" >
            <<dd>> 
     </$list>
</$wikify> 


Regards

Mohammad Rahmani

unread,
Feb 21, 2021, 7:37:10 AM2/21/21
to tiddl...@googlegroups.com
Instead of
\define me()
{{!!query}}
\end

<$wikify name="ss" text=<<me>> >
     <$list filter=<<ss>> variable="dd" >
            <<dd>> 
     </$list>
</$wikify> 

You should be able to use a much simpler solution

<$list filter="[subfilter{!!query}]" variable=dd>
<<dd>>
</$list



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.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/5031d264-96ea-4004-9335-70d375728f77n%40googlegroups.com.

Mohammad Rahmani

unread,
Feb 21, 2021, 7:38:34 AM2/21/21
to tiddl...@googlegroups.com
<$list filter="[subfilter{!!query}]" variable=dd>
<<dd>>
</$list>

The last > was forgotten in previous post

Best wishes
Mohammad

Mohamed Amin

unread,
Feb 21, 2021, 8:03:36 AM2/21/21
to TiddlyWiki
Thanks a lot Mohammad, I really appreciate your answer

"subfilter" seems VERY powerful and I didn't use it before now

Thanks a agian

Mat

unread,
Feb 21, 2021, 8:04:12 AM2/21/21
to TiddlyWiki
Probably even:

<$list filter={{!!query}}>

</$list>

The empty line is important if you want the result as a list. Note that the !!query only refers to the current tiddlers query field. In your OP you mention reusing it in any tiddler. So if you want one filter to be reused in any tiddler, you can put the filter in a separate tiddler and then refer to it as filter={{mytiddler}}.


<:-)

Mohamed Amin

unread,
Feb 21, 2021, 8:27:21 AM2/21/21
to TiddlyWiki
Thanks a million Mat for your answer, it's very surprising it is working with me now as I tried it before with no luck.

realy appreciate your help

Mohammad Rahmani

unread,
Feb 21, 2021, 11:38:39 AM2/21/21
to tiddl...@googlegroups.com
On Sun, Feb 21, 2021 at 4:33 PM Mohamed Amin <msam...@gmail.com> wrote:
Thanks a lot Mohammad, I really appreciate your answer

You are welcome!

"subfilter" seems VERY powerful and I didn't use it before now

I subfilter is very powerful as you may use it in combination with other filters like

<$list filter="[subfilter{!!query}] +[limit[2]]" variable=dd>  
This will limit outputs to two items. 

Best wishes
Mohammad

Reply all
Reply to author
Forward
0 new messages