Using the List Widget for OR Operations?

240 views
Skip to first unread message

Zaphod Beeblebrox

unread,
Sep 12, 2016, 3:00:52 AM9/12/16
to TiddlyWiki
Hello, everyone :)

I have been using the List Widget to great effect for determining whether or not to display a particular item, section, link, etc., based on the presence or lack of a certain field within a tiddler:

<$list filter="[<currentTiddler>has[zcheader]]">
<div class="QuoteBox1"><span id="HeaderBlue">{{!!zcheader}}:</span> {{!!zcomment}}</div>
</$list>


But now I've run into a dilemma with the last part of a template tiddler that must make a choice of whether to display a section or not, depending on whether ANY ONE of four different fields exist.

I just can't figure out the syntax to combine three list filters into one (if that can even be done), nor does having three nested lists work.

Here's the (non-working) last test I made:

<$list filter="[<currentTiddler>has[posters]]">
<$list filter="[
<currentTiddler>has[lobbycards]]">
<$list filter="[
<currentTiddler>has[disccovers]]">
<$list filter="[
<currentTiddler>has[misc]]">
<div style="Container">
<$transclude tiddler="$:/_Layout_ButtonSection3"/>
</div>
</$list>
</$list>
</$list>
</$list>

Can anyone shed some light on a solution?

Thankees in Advance :)

--Zaphod

PMario

unread,
Sep 12, 2016, 4:31:21 AM9/12/16
to TiddlyWiki
Hi Zaphod,

There are always several methods to achieve something in TW. Using the list widget as you do here is one of them.
IMO the $reveal widget in combination with the tw transclude mechanism and the transclude widget would be a better fit here.

But this is my impression having a very fast view at the problem. So I'd need to do some experiments - later today - to be sure.

have fun!
mario

Jeremy Ruston

unread,
Sep 12, 2016, 4:39:57 AM9/12/16
to tiddl...@googlegroups.com
Hi Zaphod

Try this:

<$list filter="[<currentTiddler>has[posters]] [<currentTiddler>has[lobbycards]] [<currentTiddler>has[disccovers]] [<currentTiddler>has[misc]] +[limit[1]]">

<div style="Container">
<$transclude tiddler="$:/_Layout_ButtonSection3"/>
</div>
</$list>

Best wishes

Jeremy

--
Jeremy Ruston

Zaphod Beeblebrox

unread,
Sep 16, 2016, 8:31:02 PM9/16/16
to TiddlyWiki
On Monday, September 12, 2016 at 4:39:57 AM UTC-4, Jeremy Ruston wrote:
Hi Zaphod

Try this:

<$list filter="[<currentTiddler>has[posters]] [<currentTiddler>has[lobbycards]] [<currentTiddler>has[disccovers]] [<currentTiddler>has[misc]] +[limit[1]]">
<div style="Container">
<$transclude tiddler="$:/_Layout_ButtonSection3"/>
</div>
</$list>
 
Thank You so much, Jeremy - That did the trick nicely :)


PMario said:
 
I'm always open to new suggestions from those that know more than me (which, when it comes to TW, includes just about everyone! :-P ).

--Zaphod

PMario

unread,
Sep 18, 2016, 5:26:51 AM9/18/16
to TiddlyWiki
On Saturday, September 17, 2016 at 2:31:02 AM UTC+2, Zaphod Beeblebrox wrote:
PMario said:
There are always several methods to achieve something in TW. Using the list widget as you do here is one of them.
IMO the $reveal widget in combination with the tw transclude mechanism and the transclude widget would be a better fit here.

But this is my impression having a very fast view at the problem. So I'd need to do some experiments - later today - to be sure.
 
I'm always open to new suggestions from those that know more than me (which, when it comes to TW, includes just about everyone! :-P ).

I did make some tests, but with the existing reveal widget, it gets more complicated than using the list filter to mimic the reveal behaviour. .. So imo no different possibility from my side :)

-m



Jed Carty

unread,
Sep 18, 2016, 7:25:42 AM9/18/16
to TiddlyWiki
I have been looking at logical operations with filters for a while. Since you can do a nor b by [all[]]-[tag[a]]-[tag[b]] you should be able to do any logical statement that uses the operators tag, has, field and is (maybe others also, I will make a list) using a single filter.

I will write up some notes and post them later.

Tobias Beer

unread,
Sep 18, 2016, 10:49:44 AM9/18/16
to TiddlyWiki
Hi Jeremy, 
 
Try this:

<$list filter="[<currentTiddler>has[posters]] [<currentTiddler>has[lobbycards]] [<currentTiddler>has[disccovers]] [<currentTiddler>has[misc]] +[limit[1]]">
<div style="Container">
<$transclude tiddler="$:/_Layout_ButtonSection3"/>
</div>
</$list>

How can I do the negating counterpart, e.g. does NOT have any of...?

There's a PR that would possibly address that use case:

is[empty] filter operator
https://github.com/Jermolene/TiddlyWiki5/pull/2186

I'll leave a comment there to see if I can spark some feedback.

Best wishes,

Tobias. 

Jeremy Ruston

unread,
Sep 18, 2016, 11:19:03 AM9/18/16
to tiddl...@googlegroups.com
Hi Tobias

How can I do the negating counterpart, e.g. does NOT have any of...?

It's messy; one has to use the emptyMessage attribute:

<$list filter="[is[current] -[has[posters]] -[has[lobbycards]]" emptyMessage=<<myMacro>>/>

(Typed on my phone, so may not be 100% correct!)

Best wishes

Jeremy


There's a PR that would possibly address that use case:

is[empty] filter operator
https://github.com/Jermolene/TiddlyWiki5/pull/2186

I'll leave a comment there to see if I can spark some feedback.

Best wishes,

Tobias. 

--
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 post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/fcd6e81d-a394-4ec5-b8ad-35b644bb2326%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jed Carty

unread,
Sep 18, 2016, 11:30:32 AM9/18/16
to TiddlyWiki
Jeremy beat me to it.

You could also use

<$list fiter="[is[current]!has[posters]!has[lobbycards]!has[discovers]]">
This is equavilent to the filter [is[current]]-[has[posters]]-[has[lobbycards]]-[has[discovers]] returning nothing
</$list>

and avoid the empty message part. I just realized that in the writeup I did I got nor and nand backwards in all of my examples and I need to rewrite them. I will hopefully put up the fixed explanation later tonight. There not being any explanation of the filters in terms of digital logic or set theory operations has been bugging me so I need to just write it and be done.

Jed Carty

unread,
Sep 18, 2016, 4:42:35 PM9/18/16
to TiddlyWiki
I put my notes here, hopefully they will be useful. I am really not sure that they will be very helpful to anyone who doesn't have at least some background in digital logic and due to the limits of the symbols my keyboard makes easily the notation isn't very good. Let me know if you see any mistakes or have any questions.

The take away from this is that if you want to do something that uses only filter operators that take an input list and return values based on a binary test (which is most of them) than you should be able to do any filtering operation with a single list widget.

HansWobbe

unread,
Sep 19, 2016, 5:16:15 AM9/19/16
to TiddlyWiki
I found your notes to be quite helpful.  Thanks for sharing them and for all of your many contributions to the community.

Regards,
Hans


On Sunday, September 18, 2016 at 4:42:35 PM UTC-4, Jed Carty wrote:
... I am really not sure that they will be very helpful to anyone who doesn't have at least some background in digital logic and due to the limits of the symbols my keyboard makes easily the notation isn't very good. Let me know if you see any mistakes or have any questions.

Zaphod Beeblebrox

unread,
Sep 19, 2016, 1:23:14 PM9/19/16
to TiddlyWiki
PMario said:

I did make some tests, but with the existing reveal widget, it gets more complicated than using the list filter to mimic the reveal behaviour. .. So imo no different possibility from my side :)

Thank You for testing, anyway :)


@Jed:

Thanks so much for your comprehensive breakdown of the Logic Operators - That really helps a lot! :)

--Zaphod
Reply all
Reply to author
Forward
0 new messages