[tw5] Conditional Reveal based on whether tiddler title shows up in fields of other tiddlers

Hello!

Okay, so the context for this is that I have, or will have, a database of many, many interrelated individuals. Each of those individuals has a ‘mother’ and a ‘father’. I can currently get tiddlywiki to display lists of children each individual has, based on their name showing up in the mother or father field of another tiddler. What I can’t figure out how to do is get the ‘Children’ row of the table not to show when an individual has no children.

For other fields I can do something like this:
<$list filter="[all[current]has[secondaryeducation]]">

''Secondary Education'' <$link to={{!!secondaryeducation}} />

When an individual doesn’t have the secondaryeducation field, the row doesn’t show up in the sidebox.

My current set up for listing children looks like this

<$list filter="[all[current]gender[female]]">

''Children'' <> <$list filter="[all[current]gender[male]"> ''Children'' <> <$list filter="[all[current]has[id]]">

If the individual is female, it looks for instances of the title of the individuals tiddler being listed as the mother in other tiddlers. Vice versa for males.

I’ve fiddled with lots of widgets. I think the problem is that this syntax [field:father{!!title}] doesn’t play well…

Also, if you have better alternative methods of achieving this goal, I’m all ears! I know filling in a ‘Children’ field, would solve this problem, but I want to cut manual data input to a minimum, and in principle all biological familial relationships (siblings, aunts, grandparents…etc.) can be expressed in mother-child, and father-child relationships.

Whoops! Well I just replied but it’s been so long since I came back to Google Groups that I forgot to use Reply All vs. Reply to Author… hopefully that message still made it to you! (normally I only monitor https://talk.tiddlywiki.org/ these days) - sorry about that.

Your “male” line has an error. There is a missing square bracket on the end:

<$list filter="[all[current]gender[male]">

Since you don’t have a label that says “mother” or “father”, I don’t know why you have two gender loops.

You should be able to add a filter operator to the gender list loop

<$vars haschild="[all[tiddlers]field:father{!!title}limit[1]]">
<$list filter="[all[current]gender[male]filter]">

''Children'' <>

Hello,

That worked perfectly, thanks! I knew there was some kind of syntax trick I was missing. Honestly, the reason for the two gender loops was just my own confusion. Intuitively, I couldn’t think of another way to list parent-child relationships in a way that was agnostic towards which parent it was - now I realise I could have had

<><> and that would have worked.

Looking at it, I agree there are still possibly needless loops - although it does the job, so I’m not complaining!

<$vars haschild="[all[tiddlers]field:mother{!!title}limit[1]]">
<$list filter="[all[current]gender[female]filter]">

''Children'' <> <$vars haschild="[all[tiddlers]field:father{!!title}limit[1]]"> <$list filter="[all[current]gender[male]filter]"> ''Children'' <>

I’ve tinkered with it to produce this:

<$vars haschild="[all[tiddlers]field:mother{!!title}field:father{!!title}sum[]limit[1]]">
<$list filter="[all[current]filter]">

''Children'' <><>

Which seems to work and is a lot less wordy

Thanks a lot!