Populating a Select from a user input term

127 views
Skip to first unread message

Stephen Kimmel

unread,
Apr 1, 2016, 5:06:54 PM4/1/16
to TiddlyWiki
A regular search generates a list of links. Instead of that I want to populate a $Select widget list. I've been able to populate the $Select widget list from a $List that includes a search operator that has a hard coded entry in the filter using something like this

<$select>
<$list filter='[all[shadows+tiddlers]tag[WikiText]search[quote]sort[title]]'>
<option value=<<currentTiddler>>><$view field='caption'/></option>
</$list>
</$select>

but nothing I've tried has allowed me to put something changeable in there like.

<$list filter='[all[shadows+tiddlers]tag[WikiText]search[{{$:/temp/searchterm}}]sort[title]]'>

My luck with variables hasn't been any better.

<$list filter='[all[shadows+tiddlers]tag[WikiText]search[<<searchterm>>]sort[title]]'>

This seems like it ought to be a straightforward problem but it has me stumped. Anyone out there have a way of doing this?

PMario

unread,
Apr 1, 2016, 5:55:49 PM4/1/16
to tiddl...@googlegroups.com
Hi,

try this:

<$select>
<$list filter='[all[shadows+tiddlers]tag[WikiText]search{$:/temp/searchterm}sort[title]]'>

<option value=<<currentTiddler>>><$view field='caption'/></option>
</$list>
</$select>

see: http://tiddlywiki.com/#TextReference

----------------

I used this to test the stuff

<$edit-text tiddler="$:/temp/searchterm" tag=input/>

{{{[tag[WikiText]search{$:/temp/searchterm}]}}}

-mario

Mark S.

unread,
Apr 1, 2016, 5:58:50 PM4/1/16
to TiddlyWiki
Using transclusion in a filter has a special syntax -- just put the item in single curly brackets instead of bracket and double curlies . So your filter now looks like:


<$list filter='[all[shadows+tiddlers]tag[WikiText]search{$:/temp/searchterm}sort[title]]'>

HTH
Mark

PMario

unread,
Apr 1, 2016, 5:59:16 PM4/1/16
to TiddlyWiki
On Friday, April 1, 2016 at 11:55:49 PM UTC+2, PMario wrote:
<option value=<<currentTiddler>>><$view field='caption'/></option>


IMO here is a problem! .. If a tiddler has no caption field, it creates an empty element in the select box. So either you need to make sure this never happens or you need a title fallback.

-mario

Stephen Kimmel

unread,
Apr 1, 2016, 10:09:31 PM4/1/16
to TiddlyWiki
Mario and Mark,

Many thanks. Your reworking was exactly what I needed. I had missed the detail of the single curly bracket when used with a filter.

I went with the caption field rather than the title because some of what I'm having the user look-up are system files which I find have names that can be confusing. You're right. A tiddler without a caption will produce a blank line and that isn't the best. Still, if I could figure some way to show the caption preferentially and the title if the caption field was blank I would be a happy camper.

Mark S.

unread,
Apr 1, 2016, 10:38:40 PM4/1/16
to TiddlyWiki
Eric Shulman explained how to do a preferential caption/title a few weeks ago:

<$view field='caption'><$view field='title'/></$view>

HTH
Mark

Stephen Kimmel

unread,
Apr 6, 2016, 9:47:00 AM4/6/16
to TiddlyWiki
Mark, (and indirectly Eric)

I am tardy thanking you for that tip. That worked like a champ.

There are times I suspect that Eric knows Tiddlywiki as well as Jeremy.

Thanks for the tip.
Reply all
Reply to author
Forward
0 new messages