Filter question: Use :filter operator

59 views
Skip to first unread message

Mohammad Rahmani

unread,
May 14, 2021, 11:36:19 AM5/14/21
to tiddl...@googlegroups.com
Issue with :filter operator

1. The variable temTid refers to tiddler xx/temp/data,
2. Tiddler xx/temp/data in its text field stores the name of another tiddler called aiche.org
3. The tiddler  aiche.org has a field called url

I want to retrieve the url value as below

\define temTid()  xx/temp/data
<$list filter="[<tempTid>get[text]] :filter[get[url]]">

</$list>

The :filter doesn't work and the $list just returns the result of the first part  [<tempTid>get[text]]
What do you think? (all of them are dynamic and the value changes in different runs)

I know I can do this in two separate steps! But I am looking for a one step solution as above


- Explanation




Best wishes
Mohammad

Saq Imtiaz

unread,
May 14, 2021, 11:40:29 AM5/14/21
to TiddlyWiki
:filter does exactly that, it filters which titles from the previous run are included based on whether its run returns a value for that title or not.

I think what you want is [<tempTid>get[text]get[url]]

Mohammad Rahmani

unread,
May 14, 2021, 12:20:54 PM5/14/21
to tiddl...@googlegroups.com
On Fri, May 14, 2021 at 8:10 PM Saq Imtiaz <saq.i...@gmail.com> wrote:
:filter does exactly that, it filters which titles from the previous run are included based on whether its run returns a value for that title or not.

But I cannot get the result by :filter, have you tried the below filter?

<$list filter="[<tempTid>get[text]] :filter[get[url]]">

</$list>

 
I think what you want is [<tempTid>get[text]get[url]]

Thanks Saq! sometimes I forgot things may be these are sign of alzheimer!



Saq Imtiaz

unread,
May 14, 2021, 12:34:35 PM5/14/21
to TiddlyWiki
You are misunderstanding the purpose of :filter.

It is used to include or exclude titles from the previous run, based on whether this filter run returns a result or not. The same principle as the filter[] operator for which I recommend reading the docs as they mostly apply here too: https://tiddlywiki.com/#filter%20Operator
 
<$list filter="[<tempTid>get[text]] :filter[get[url]]">


The first filter run says: get the text field from the tiddler whose title is in the variable tempTid
The second filter run says: exclude all titles from the previous run, if they do not have url field. 

:filter does NOT change the input titles, it only excludes or includes them in its output based on the result of its filter run.
 

Saq Imtiaz

unread,
May 14, 2021, 12:37:22 PM5/14/21
to TiddlyWiki
Another way to explain it is that:
<$list filter="[<tempTid>get[text]] :filter[get[url]]">

</$list>

is equivalent to:

<$list filter="[<tempTid>get[text]]">
<$list filter="[<currentTiddler>get[url]!is[blank]]" variable="null">

</$list>
</$list>

Mohammad Rahmani

unread,
May 14, 2021, 1:57:57 PM5/14/21
to tiddl...@googlegroups.com
Saq,
 Many thanks for the clarification and I read the document again!


This example is great! but for me they return two different results! That was my confusion!

I have attached a JSON test both above solutions!
and let me know if you see what I mean?

image.png

filter-question.json

Saq Imtiaz

unread,
May 14, 2021, 2:09:21 PM5/14/21
to TiddlyWiki
I'm on a touch device and can't test what you posted but let me clarify my examples above to:

Another way to explain it is that:
<$list filter="[<tempTid>get[text]] :filter[get[url]]">
<<currentTiddler>>
</$list>

is equivalent to:

<$list filter="[<tempTid>get[text]]">
<$list filter="[<currentTiddler>get[url]!is[blank]]" variable="null">
<currentTiddler>>
</$list>
</$list>

Mohammad Rahmani

unread,
May 14, 2021, 2:59:41 PM5/14/21
to tiddl...@googlegroups.com
On Fri, May 14, 2021 at 10:39 PM Saq Imtiaz <saq.i...@gmail.com> wrote:
I'm on a touch device and can't test what you posted but let me clarify my examples above to:

Thank you Saq,
This second example shows the same result and both show the TITLE of the filter not url!
I got your point, it passes the title and keeps it by end! It does not return the value!

Thank you for calcification!

 
--
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/fe6301a7-f1e2-48e7-8f94-478cf6313088n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages