Hide Header when ListWidget has Zero Records

52 views
Skip to first unread message

David

unread,
May 15, 2020, 11:57:11 AM5/15/20
to TiddlyWiki
With you guys' help, i have a good filter going that shows "Packed" items.

I'm inside another <ListWidget> that get a list of the Contexts.  That's where the "thisContext" var comes from.

!!! <<thisContext>>

<$list filter="[<thisContext>listed[tags]tag[PackingItem]tag[Packed]]" variable="item">
<<item>>
</$list>


What I'd like to do is only show that Header/!!! text when there are some results to see from the list that's right below it.

What are some ideas?  I played around with the reveal widget, but nothing I did seemed to work.

Eric Shulman

unread,
May 15, 2020, 12:31:09 PM5/15/20
to TiddlyWiki
On Friday, May 15, 2020 at 8:57:11 AM UTC-7, David wrote:
With you guys' help, i have a good filter going that shows "Packed" items.
I'm inside another <ListWidget> that get a list of the Contexts.  That's where the "thisContext" var comes from.
!!! <<thisContext>>

<$list filter="[<thisContext>listed[tags]tag[PackingItem]tag[Packed]]" variable="item">
<<item>>
</$list>
What I'd like to do is only show that Header/!!! text when there are some results to see from the list that's right below it.

Surround the header with the same filter with "limit[1]" added to it, like this:

<$list filter="[<thisContext>listed[tags]tag[PackingItem]tag[Packed]limit[1]]" variable="item">

!!! <
<thisContext>>
</$list>
<$list filter="[
<thisContext>listed[tags]tag[PackingItem]tag[Packed]]" variable="item">
<
<item>>
</$list>

What it does:
The limit[1] operator is used to test if there is at least 1 matching result.  If there are no results, the content of the <$list> widget is skipped.  If there is more than 1 result, the content is displayed only once.

Note that the blank line preceding the header line is important, as the "!!!" heading syntax is only permitted in "block mode" (vs. "inline mode").  Without the blank line, the "!!!" will be displayed "inline" as literal text.

enjoy,
-e

David

unread,
May 15, 2020, 12:51:26 PM5/15/20
to TiddlyWiki
Great.  I assumed there was something for that, since it seems so often needed. 

Worked great.

Thanks!

Mat

unread,
May 15, 2020, 2:27:37 PM5/15/20
to TiddlyWiki
David wrote:
Great.  I assumed there was something for that, since it seems so often needed. 

You may want to comment in this issue thread: https://github.com/Jermolene/TiddlyWiki5/issues/2202

<:-)
Reply all
Reply to author
Forward
0 new messages