Getting a complex filter into a <$select>

47 views
Skip to first unread message

Steven Schneider

unread,
Apr 27, 2020, 5:13:14 PM4/27/20
to TiddlyWiki
Hi all, I've got a challenge, trying to get a filtered list matching a field value into a select.....

I can do the filter! Just can't get it into the select.

the attached json file contains 3 tiddlers tagged "perspective" and 3 tiddlers tagged "artifacts", with some of the perspective tiddlers having fields whose names matches the title of an artifacts tiddler and whose value is "Yes", plus a tiddler named demo that has code. this works in tiddlywiki.com....





1. Select among a set of tiddlers matching a filter, tag[perspective]]:<br>

<$select tiddler='$:/perspective'>
<$list filter="[tag[perspective]]">
<option value=<<currentTiddler>>><<currentTiddler>></option>
</$list>
</$select> 
<hr>

Selected tiddler is <$link to={{$:/perspective}}/><br>

2a. List tiddlers matching tag[artifact]].......

<$list filter="[tag[artifact]]">
<<currentTiddler>><br>
</$list>

2b .....whose tiddler title match a field name with a  field value of "Yes"  in the selected perspective tiddler.



<$list filter="[tag[artifact]]">
<$vars fieldName={{!!title}} fieldValue="Yes">
<$list filter="[title{$:/perspective}has<fieldName>]">
<$list filter="[<currentTiddler>get<fieldName>match<fieldValue>]" variable="is_match">
      {{$:/perspective}} has <<fieldName>> with value of <<fieldValue>><br>
</$list>
</$list>
</$vars>
</$list>
<hr>

3. Put that list in a ``<$select>`` -- no such luck!

<$select tiddler='$:/perspective'>
<$list filter="[tag[artifact]]">
<$vars fieldName={{!!title}} fieldValue="Yes">
<$list filter="[title{$:/perspective}has<fieldName>]">
<$list filter="[<currentTiddler>get<fieldName>match<fieldValue>]" variable="is_match">
<<option value=<<fieldName>>><<fieldName>></option>
</$list>
</$list>
</$vars>
</$list>
</$list>
</$select> 
<hr>

Any suggestions, much appreciated, 

//steve.





tiddlers.json

Mark S.

unread,
Apr 27, 2020, 6:48:59 PM4/27/20
to TiddlyWiki
In #3 you put the select output into $:/perspective, which is also what you set in #1.

So I'm confused. Do you want the user to make a choice of perspective in #1, and THEN choose a field in #3, or were you hoping to choose both perspective and artifact in #3 at the same time?

In #3, as a starter, it looks like there is a mismatch between <$list> and </$list> (one extra </$list>.) though maybe my eyes are missing something.

Good luck!

Joshua Fontany

unread,
Apr 27, 2020, 6:58:43 PM4/27/20
to TiddlyWiki
You have two left-angle-brackets in front of "<<option" in example 3. Could be a simple syntax error (I hate those syntax gremlins).

Best, Josh F




On Monday, April 27, 2020 at 2:13:14 PM UTC-7, Steven Schneider wrote:
Reply all
Reply to author
Forward
0 new messages