Nested List, show Level 1 only if Level 2 exists

165 views
Skip to first unread message

JM

unread,
Feb 17, 2021, 10:40:09 AM2/17/21
to TiddlyWiki

Hi there,

I use nested lists to organize my To-Do-List

<$list filter="[tag[project]sort[title]]">
<$link to={{!!title}}>''<$view field="title"/>''</$link><br>
<$list filter="[is[current]tagging[]tag[CAD]sort[title]]">
<$link to={{!!title}}><$view field="title"/></$link><br>
</$list><br>
</$list>

Is ist possible to show only those projects, of which tiddlers with the tags project-title and CAD exist?

Eric Shulman

unread,
Feb 17, 2021, 11:10:26 AM2/17/21
to TiddlyWiki
On Wednesday, February 17, 2021 at 7:40:09 AM UTC-8 JM wrote:
<$list filter="[tag[project]sort[title]]">
<$link to={{!!title}}>''<$view field="title"/>''</$link><br>
<$list filter="[is[current]tagging[]tag[CAD]sort[title]]">
<$link to={{!!title}}><$view field="title"/></$link><br>
</$list><br>
</$list>

Is it possible to show only those projects, of which tiddlers with the tags project-title and CAD exist?

You can surround the inner $list with another $list that uses "limit[1]" to act as a test, like this:

<$list filter="[tag[project]sort[]]">
   <$link /><br>
   <$list filter="[tag{!!title}tag[CAD]limit[1]]" variable="has_CAD_tag">
      <$list filter="[tag{!!title}tag[CAD]sort[]]">
         <$link /><br>
      </$list><br>
   </$list>
</$list>

Notes:
* variable="has_CAD_tag" prevents the test from changing the value of the currentTiddler.
* simplified the inner filter to use tag{!!title} instead of is[current]tagging[]
* used <$link /> abbreviated syntax instead of verbose <$link to={{!!title}}><$view field="title"/></$link>
* used sort[] (default parameter is "title")

enjoy,
-e

JM

unread,
Feb 18, 2021, 1:28:15 AM2/18/21
to TiddlyWiki
Somehow, this doesn't work out. Projects without tasks tagged CAD still appear in the list.

Eric Shulman schrieb am Mittwoch, 17. Februar 2021 um 17:10:26 UTC+1:
Notes:
* used <$link /> abbreviated syntax instead of verbose <$link to={{!!title}}><$view field="title"/></$link>
 
Thx for the explanations. If I use just <$link /> I am not able to fotmat the title, am I?

Jens

JM

unread,
Feb 18, 2021, 1:35:15 AM2/18/21
to TiddlyWiki
Something changed. Using my first solution, the space between project title was 'big', as If there was an empty list behind the project title of projects without tasks tagged CAD. Now there is no more space between those projects and the following project.

Perhaps my description was bad (not native english ;) ). I want to mask those projects without tasks tagged CAD.

Eric Shulman

unread,
Feb 18, 2021, 5:08:22 AM2/18/21
to TiddlyWiki
On Wednesday, February 17, 2021 at 10:35:15 PM UTC-8 JM wrote:
Something changed. Using my first solution, the space between project title was 'big', as If there was an empty list behind the project title of projects without tasks tagged CAD. Now there is no more space between those projects and the following project.

That's what happens when I post a "solution" without actually trying it with some test data!

This should work better:

<$list filter="[tag[project]sort[]]">
   <$list filter="[tag{!!title}tag[CAD]limit[1]]" variable="has_tasks_with_CAD_tag">
      <$link>''<$view field="title"/>''</$link><br>
      <$list filter="[tag{!!title}tag[CAD]sort[]]">
         <$link /><br>
      </$list><br>
   </$list>
</$list> 

Notes:
* moved the "test" $list widget to surround the whole project item to suppress display of projects that don't have tasks tagged with CAD
* restored the explicit <$link>...</$link> for the project item to allow bold formatting of the title

-e

JM

unread,
Feb 18, 2021, 6:47:01 AM2/18/21
to TiddlyWiki
Thank you! :-)

Next step would be understanding what you have archieved with "limit[1]". Ist the literal content of variable relevant?

Eric Shulman

unread,
Feb 18, 2021, 8:32:34 AM2/18/21
to TiddlyWiki
On Thursday, February 18, 2021 at 3:47:01 AM UTC-8 JM wrote:
Next step would be understanding what you have archieved with "limit[1]". Ist the literal content of variable relevant?
 
The $list widget filter, [tag{!!title}tag[CAD]], only produces output when there are matching tiddlers. If there are more than one match, the body of the widget is output multiple times.  By adding limit[1] to the filter the body will only be shown once.

Note: rather than referencing {!!title}, the filter could also have been written as [tag<currentTiddler>tag[CAD]], which perhaps more clearly shows how the currentTiddler's title is being used.

Adding the variable="..." parameter to the $list widget assigns the matching tiddler's title to the specified variable name.  For this particular use-case, you don't actually need to reference this variable inside the $list body; it is only used to prevent the $list widget from changing the value of <currentTiddler>.  Thus, the name of the variable isn't important and I have used it simply to describe the purpose of the "test" filter.

Hope this explains things...

-e

JM

unread,
Feb 18, 2021, 11:29:47 AM2/18/21
to TiddlyWiki
Yes, thank you very much!

JM

unread,
May 26, 2021, 10:15:49 AM5/26/21
to TiddlyWiki
Hi,

bringing this up again ...

I want to exclude projects with tasks tagged with 'A'. Somehow it doesn't work out as expected (well it did, something changed and I'm not sure what and why ... :-\ )

I added !tag[A] in the second filter:

<$list filter="[tag[project]sort[]]">
   <$list filter="[tag{!!title}tag[CAD]limit[1]!tag[A]]" variable="has_tasks_with_CAD_tag">
      <$link>''<$view field="title"/>''</$link><br>
      <$list filter="[tag{!!title}tag[CAD]sort[]]">
         <$link /><br>
      </$list><br>
   </$list>
</$list> 

This screwed the whole list. Perhaps this isn't the correct way doing this ...

Jens

Eric Shulman

unread,
May 26, 2021, 10:37:38 AM5/26/21
to TiddlyWiki
On Wednesday, May 26, 2021 at 7:15:49 AM UTC-7 JM wrote:
I want to exclude projects with tasks tagged with 'A'. Somehow it doesn't work out as expected (well it did, something changed and I'm not sure what and why ... :-\ )
I added !tag[A] in the second filter:
<$list filter="[tag[project]sort[]]">
   <$list filter="[tag{!!title}tag[CAD]limit[1]!tag[A]]" variable="has_tasks_with_CAD_tag">
      <$link>''<$view field="title"/>''</$link><br>
      <$list filter="[tag{!!title}tag[CAD]sort[]]">
         <$link /><br>
      </$list><br>
   </$list>
</$list> 

You need to put the "!tag[A]" syntax before the limit[1], and then also add it to the inner filter, like this:

<$list filter="[tag[project]sort[]]">
   <$list filter="[tag{!!title}tag[CAD]!tag[A]limit[1]]" variable="has_tasks_with_CAD_tag_and_not_A_tag">
      <$link>''<$view field="title"/>''</$link><br>
      <$list filter="[tag{!!title}tag[CAD]!tag[A]sort[]]">
         <$link /><br>
      </$list><br>
   </$list>
</$list> 

enjoy,
-e

JM

unread,
May 26, 2021, 10:56:54 AM5/26/21
to TiddlyWiki
Thank You!

I was somehow confused, because I'm sure it worked some time ago. Is it possible that the alphabetical order of the tags has something to do with this? Because there is another nested list (with different tags as parameters) and it worked out well.
Reply all
Reply to author
Forward
0 new messages