Forgive my coding ignorance! Trying to display a list of Tiddlers (and their icons) filtered by tags chosen through a user input value
My current code is shown below but problems are:
text box works to allow user input, but only one character at a time
It does correctly create a field “search” and add the input text
Filter works, but not when trying to use the value of the field “search”. Not transcluding correctly?
Any help very much appreciated. Patrick
<br>
<$edit-text field="search" default="" placeholder="search tags"
tag="input"/>
<$button>enter search
<$list filter="search" variable=item>
<$action-sendmessage $message="tm-add-field" $param=<<item>>/>
</$list>
<$action-setfield search
={{!!search}}/>
</$button>
search is {{!!search}}
<$list filter="[tag[{!!search}]]">
<$transclude tiddler={{!!icon}}/> <$link/><br>
</$list>
Try this:
<$edit-text field="search" default="" placeholder="search tags"/>
search is {{!!search}}
<$list filter="[tag{!!search}]">
<$transclude tiddler={{!!icon}}/> <$link/><br>
</$list>
Notes:
The $button isn’t needed. The search tiddler field is automatically created/updated as you enter each character into the $edit-text input.
In the filter syntax, the brackets surrounding the parameter indicate how to interpret that parameter:
square brackets enclose literal text: [sometext]
curly brackets enclose tiddler/field references: {tiddlertitle} or {!!fieldname}
angle brackets enclose variable references: <varname>
Thus, for your filter, you write: filter="[tag{!!search}]" to use the value that was entered into the tiddler search field.
enjoy,
-e
P.S. Also note that, when entering code into your Discourse post, put tripled back ticks (```) on lines before and after the code. This will allow your code to be displayed as literal text without interpreting it as HTML syntax. I took the liberty of editing your original post to add the backticks around the code.
EricShulman:
filter="[tag{!!search}]"
Thanks so much - it works perfectly (sure you knew it would!). I’ll bear in mind back ticks next time for quoting code.
Now need to try and understand where I went wrong. Thanks again
Patrick