TW5 show list of values in a field

299 views
Skip to first unread message

Jon

unread,
Nov 24, 2016, 12:14:28 PM11/24/16
to tiddl...@googlegroups.com
Hi,

I'd like to have a drop down which selects from a list of tiddlers tagged with "A" and simultaneously shows the values of the field "B" associated with each tiddler.

This does the first bit:

<$select tiddler="$:/temp/tag1">

   <$list filter="[tag[A]tags[]sort[]]">
      <option value=<
<currentTiddler>>><<currentTiddler>></option>
   </$list>
</$select>


(cobbled together from something else so some elements could be unnecessary) 

But I can't figure out the rest of it.

I'm guessing that <$view field="B"/> would be incorporated somehow.


Thanks
Jon

Mark S.

unread,
Nov 25, 2016, 12:10:30 AM11/25/16
to TiddlyWiki
Try:

<$select tiddler="$:/temp/tag1">
   <$list filter="[tag[A]each[field]get[field]]" variable="field">
      <option value=<
<field>>><<field>></option>
   </$list>


Where "A" is the tag and "field" is the field.

HTH
Mark

Jon

unread,
Nov 25, 2016, 1:50:26 AM11/25/16
to TiddlyWiki
Hi Mark,

Many thanks for that and it seems to be half way there.

The tag is "family" and the field is "keyword".

I wasn't quite sure whether every appearance of field needed to be substituted with the actual field name and found that:

<$select tiddler="$:/temp/tag1">
   <$list filter="[tag[family]each[keyword]get[keyword]]" variable="field">
      <option value=<<field>>><<field>></option>
   </$list>


Produces the same result as:

<$select tiddler="$:/temp/tag1">
   <$list filter="[tag[family]each[keyword]get[keyword]]" variable="keyword">
      <option value=<
<keyword>>><<keyword>></option>
   </$list>


So something might be adrift.

Both give a dropdown containing a single line showing the values of "keyword" on this line within the drop down.

Ideally, I'd like the dropdown to contain the list of "family" and then underneath the box, the values of "keyword" for that family.

Thanks
Jon

Riz

unread,
Nov 25, 2016, 12:03:29 PM11/25/16
to TiddlyWiki

Try this

<$select tiddler="$:/temp/tag1">

   <$list filter="[tag[
family]]">
      <option value={{!!keyword}}
><<currentTiddler>><br>@@color:red;{{!!keyword}}@@</option>
   </$list>
</$select>


Jon

unread,
Nov 25, 2016, 2:52:20 PM11/25/16
to TiddlyWiki
Hi Riz,

That produces the dropdown containing a list of tiddlers tagged with "family" but the field values of "keyword" are also contained within the box rather than being placed in a list outside it.

Thanks
Jon

Mark S.

unread,
Nov 26, 2016, 12:29:54 AM11/26/16
to TiddlyWiki
I think what you what is a select tag with option groups inside.

I created 3 tiddlers with tags GroupA and GroupB variously assigned. Each tiddler had a field called eponymously "field". Each tiddler also had a field called "findme" so I could limit my list to to just the tiddlers of interest. This code then produces a select widget with a group for tag GroupA and GroupB, with their field contents specified inside of each group.

<$select tiddler="$:/temp/tag1">
   <$list filter="[has[findme]tags[]]" variable="mytag">
<optgroup label=<
<mytag>>>
<$list filter="[tag
<mytag>get[field]]" variable="field">
      <option value=<
<field>>><<field>></option>
 </$list>  
</optgroup>
</$list>

</$select>



Overall, it would probably be better if you explained your actual use-case rather than looking for detailed technical recipes.

Good luck!
Mark

Jon

unread,
Nov 26, 2016, 1:39:30 PM11/26/16
to tiddl...@googlegroups.com
Hi Mark,

Sorry, I couldn't get that to work - no doubt it's something my end!

This is my use case:

I have a list of tiddlers tagged with "family" and I also want to associate various keywords with each of  them but I'd rather not add them as tags because there would be too many and they aren't tags I'd use elsewhere, so I thought I could enter them as fields instead.

Therefore, I'd like to select a particular tiddler tagged with "family" which would then show the associated keywords (field values).

Ideally this would be using a drop down for the list and the field values would be shown in the body of the tiddler.

Hope that makes sense.

Thanks
Jon



On Thursday, 24 November 2016 17:14:28 UTC, Jon wrote:

Mark S.

unread,
Nov 26, 2016, 5:08:42 PM11/26/16
to TiddlyWiki
Can you lay out a few tiddlers with the data the way you want?

What do you expect to see in the select? Just a list of values?

When you say, "field values would be shown in the body of the tiddler" do you mean in the tiddler with the select widget, or in each tiddler that has been tagged with "family" ? If the latter, then what you want is set up a view template. Search the forum for references to template.

Good luck!
Mark

Jon

unread,
Nov 26, 2016, 5:53:14 PM11/26/16
to TiddlyWiki
Hi Mark,

The select would show the list of tiddlers tagged with "family" and the field values (for the field "keyword") would be in the same tiddler as the select widget, so there would be a drop down box and the field values are underneath it - sorry if it wasn't clear before.

Thanks
Jon

Mark S.

unread,
Nov 26, 2016, 6:48:05 PM11/26/16
to TiddlyWiki
That sounds exactly like what Riz gave you. It would produce a select widget populated with the values contained in the keyword field. What do you want beyond that?

Good luck,
Mark

Jon

unread,
Nov 27, 2016, 2:46:27 AM11/27/16
to tiddl...@googlegroups.com
It would produce a select widget populated with the values contained in the keyword field

Sorry Mark, but that's not what I want.

I need the values of the keyword field outside the widget, in the body of the tiddler (which contains the select widget)


Thanks
Jon

Riz

unread,
Nov 27, 2016, 12:40:26 PM11/27/16
to TiddlyWiki


Sorry Mark, but that's not what I want.

I need the values of the keyword field outside the widget, in the body of the tiddler (which contains the select widget)


<$select tiddler="$:/temp/familykeyword">

   <$list filter="[tag[
family]]">
      <option value={{!!keyword}}
><<currentTiddler>></option>
   </$list>
</$select>

Now wherever you want the keyword to appear, say the body of the tiddler containing the select widget, just add {{
$:/temp/familykeyword}}

Sincerely
Riz

Jon

unread,
Nov 27, 2016, 1:26:23 PM11/27/16
to TiddlyWiki
Riz, that is almost perfect!!

I just need the keywords to show in a list rather than on a single line.

How do I incorporate a line break or something similar?

Many thanks
Jon

Jon

unread,
Nov 28, 2016, 2:20:11 PM11/28/16
to tiddl...@googlegroups.com
Hi,

In terms of putting each field value on a new line, I found this CSS trick which seems to work!


.newline {
word-spacing: 9999999px;
}

<$select tiddler="$:/temp/familykeyword">
   <$list filter="[tag[family]]">
      <option value= {{!!keyword}}><<currentTiddler>></option>
   </$list>
</$select>

@@.newline
<div>
{{ $:/temp/familykeyword }}
</div>
@@

(first 3 lines being in a separate tiddler tagged with $:/tags/Stylesheet)



Thanks for help on this.

Jon
Reply all
Reply to author
Forward
0 new messages