How do I filter a list of tiddlers based on whether current title appears in a specific field of any one of another collection of tiddlers
I feel as though this must be easily doable, but I’m stumped. I’m building a wiki for a local political party. For an upcoming election, I’m trying to display a list of candidates by position and party. I have tiddlers tagged "Party"
(e.g. “Democratic”, “Republican”, “Independent”, “Green”, “Libertarian”, etc.), and I have a collection of tiddlers tagged “Candidacy”, which look like this:
contest: 2023-General
name: Scott Sauyet
organization: Board of Education
party: Democratic
But some parties will not have candidates in the current election, and I don’t want to waste a whole column of my grid if there are no candidates at all.
Currently, I am creating the table header with code that looks like this:
<tr><th>Position</th><$list filter="[tag[Party]]"><th class={{!!title}}>{{!!title}}</th></$list></tr>
and doing something similar for the body, but I’m wondering how to change that filter ([tag[Party]]
) to something that checks if there are any tiddlers tagged "Candidacy"
which have a party
field of the current title.
I want it to be something like this:
[tag[Party]] :filter[tag[Candidacy]party<currentTiddler>]
But that is yielding no results. Any suggestions?
A temporary version of this is live at 2023 Slate. The relevant tiddler looks like this:
<table class="candidates">
<thead>
<tr><th>Position</th><$list filter="[tag[Party]]"><th class={{!!title}}>{{!!title}}</th></$list></tr>
</thead>
<tbody>
<$list filter='[tag[Elected Positions]org-type[elected]]' variable="pos">
<tr><th>{{{ [<pos>get[title]] }}}</th><$list filter="[tag[Party]]" variable="party"><td class={{{ [<party>get[title]] }}}><<list-links filter:"[tag[Candidacy]party<party>organization<pos>] :map[get[name]]" >></td></$list></tr>
</$list>
</tbody>
</table>