[TW5] Filter syntax to list all values of a field

1,266 views
Skip to first unread message

Bob Flandard

unread,
Sep 29, 2015, 2:17:52 PM9/29/15
to TiddlyWiki
Hello,

I'm trying to make a list of all the values of a specific field "Some Field", for all tiddlers (probably not system or shadow tiddlers, but with and without would be interesting) tagged with "Some Tag".

This doesn't work:
<$list filter="[tag[Some Tag]field:Some Field[]]"/>

Any ideas?

Thanks, Bob

Eric Shulman

unread,
Sep 29, 2015, 2:45:12 PM9/29/15
to TiddlyWiki
You were close.  Use the "has[...]" filter to select tiddlers that have the desired field, and then output the field value inside the <$list> widget.

<$list filter="[tag[Some Tag]has[Some Field]"/>{{!!Some Field}}</$list>


-e

Tobias Beer

unread,
Sep 29, 2015, 2:52:05 PM9/29/15
to tiddl...@googlegroups.com
Hi Bob,
 
I'm trying to make a list of all the values of a specific field "Some Field", for all tiddlers (probably not system or shadow tiddlers, but with and without would be interesting) tagged with "Some Tag".

Try this on tiddlywiki.com

{{{ [tag[WikiText]each[caption]get[caption]sort[title]] }}}

This lists all the unique captions of tiddlers tagged WikiText.

Best wishes,

— tb

Bob Flandard

unread,
Sep 29, 2015, 5:05:48 PM9/29/15
to TiddlyWiki
Hello Eric and tb,

Thank you for your suggestions. I couldn't get Eric's code to work without removing some stuff off the end of it and adding a single "]", but then it listed tiddler names not field values, so I must have broken it.

<$list filter="[tag[some field]has[field_name_1]]"/>

tb's code worked as expected when added to new tiddler, but when I add it to a tiddler with:

tag =
$:/tags/EditTemplate


field list-after=
$:/core/ui/EditTemplate/body


and text=

<$list filter="[all[current]tag[some field]]">

field_name_1: <$select field="field_name_1">
<option value=''></option>
<option>value 1</option>
<option>value 2</option>
<option>value 3</option>
</$select>

field_name_2: <$select field="field_name_2">
<option>default value</option>
<option>
{{{ [tag[some field]each[field_name_2]get[field_name_2]sort[title]] }}}
</option>
</$select>

</$list>


The
<option>
{{{ [tag[some field]each[field_name_2]get[field_name_2]sort[title]] }}}
</option>

part just concatenates all the field values into a single line with no spaces, rather than a list of separately selectable options, that I was hoping for.

Where might I have gone wrong?

Thank you, Bob



Evolena

unread,
Sep 29, 2015, 5:21:12 PM9/29/15
to TiddlyWiki
Le mardi 29 septembre 2015 23:05:48 UTC+2, Bob Flandard a écrit :
The
<option>
{{{ [tag[some field]each[field_name_2]get[field_name_2]sort[title]] }}}
</option>

part just concatenates all the field values into a single line with no spaces, rather than a list of separately selectable options, that I was hoping for.

Where might I have gone wrong?

Thank you, Bob


This syntax transcludes a list of tiddlers (in fact, here each field value retrieved by the get operator is considered as a tiddler's title) matching a specified filter. This is not suitable for the usage with the options of the select widget, where you want an explicit list widget outside the option element, so that each value returned by the filter becomes an option.

<$list filter="[tag[some field]each[field_name_2]get[field_name_2]sort[title]]">
<option>

<$view field="title"/>
</option>
</$list>

You can also use <<currentTiddler>> instead of the view widget.

Bob Flandard

unread,
Sep 29, 2015, 5:50:08 PM9/29/15
to TiddlyWiki
Hello Evolena,

Most of my TW5 belongs to you!

Do you have stuff on TiddlySpot that I might scrutinize?

Many thanks for yet again solving my imponderable conundrum. If Jeremy dies or gets incurable hiccups, you'll have to take-over :)

All the best, Bob

Evolena

unread,
Sep 30, 2015, 2:24:45 AM9/30/15
to TiddlyWiki
Le mardi 29 septembre 2015 23:50:08 UTC+2, Bob Flandard a écrit :
Hello Evolena,

Most of my TW5 belongs to you!

Do you have stuff on TiddlySpot that I might scrutinize?

Thank you.

No, I don't have such a site. And if I had, it would be in French ;)
But some of my answers are adapted by Tobias Beer in his fantastic tb5

Tobias Beer

unread,
Sep 30, 2015, 2:26:29 AM9/30/15
to tiddl...@googlegroups.com
Hi Bob,

To learn more about the syntax for {{{ [filter[]] }}} , try searching for "{{{" on tiddlywiki.com...
...both are quite essential to creating the kind of stuff you desire.
Also, the first example in the SelectWidget documentation
shows you how to populate a select via the ListWidget based on a filter.

As for...

You can also use <<currentTiddler>> instead of the view widget.

Be aware that using <<currentTiddler>>
works well in this context, but elsewhere it might
wikify / transclude whatever currentTiddler holds,
e.g. if it is a WikiWord it will become a link.

For example, try this on tiddlywiki.com and note how
some parts of some results become links while others don't:

<$list filter="[tag[TableOfContents]]">

<
<currentTiddler>>
</$list>

Same with...

<$list filter="[tag[TableOfContents]]">

{{!!title}}
</$list>

Now try that again using the view widget inside your list...

<$list filter="[tag[TableOfContents]]">

<$view field="title"/>
</$list>

or the text widget as either...

<$list filter="[tag[TableOfContents]]">

<$text text=<
<currentTiddler>>/>
</$list>

or...

<$list filter="[tag[TableOfContents]]">

<$text text={{!!title}}/>
</$list>

Best wishes,

— tb

Bob Flandard

unread,
Sep 30, 2015, 3:44:13 AM9/30/15
to TiddlyWiki
Thanks Evolena and tb,

That's really helpful to have been warned about the different behaviors of <<currentTiddler>> and the view widget.

I agree that tb5 is rather good and I often have a butcher's gander.

All the best, Bob
Reply all
Reply to author
Forward
0 new messages