You’ve run up against a very common misunderstanding about filter syntax. When using a filter operator, the brackets surrounding the operand value are used to indicate how to handle that operand.
- single square brackets are used to surround literal text values
(e.g.,narrative[someUUID]
) - single angle brackets are used to surround variable references
(e.g.,narrative<fieldvalue>
) - single curly braces are used to surround tiddler field references
(e.g.,narrative{!!fieldname}
ornarrative{TiddlerName}
)
Note that, unlike wikitext syntax which uses doubled brackets, within filter syntax the brackets are not doubled.
Thus, in your filter, you could write:
<$list filter="[narrative<fieldvalue>!tag[narrative]sort[]]">
...
</$list>
which uses the value of the fieldvalue
variable as the operand value.
Alternatively, you could also write it like this:
<$list filter="[narrative{!!$fieldname$}!tag[narrative]sort[]]">
...
</$list>
which constructs a field reference operand for the $fieldname$
of the current tiddler by adding a leading “!!
” prefix to the $fieldname$
parameter
Some other notes:
Instead of using a $set
widget like this:
<$set name=fieldvalue value={{{ [all[current]get[$fieldname$]] }}}>
you could use the more compact $let
widget:
<$let fieldvalue={{{ [all[current]get[$fieldname$]] }}}>
Within the filter syntax you can also use the slightly more performant <currentTiddler>
variable instead of the all[current]
filter operator, like this:
<$let fieldvalue={{{ [<currentTiddler>get[$fieldname$]] }}}>
You could also simplify it even further by skipping the “filtered transclusion” syntax (tripled curly braces) entirely, and just use doubled-curly braces to make a direct field reference like this:
<$let fieldvalue={{!!$fieldname$}}>
(note that this syntax uses doubled-curly braces, since it is NOT a within a filter!)
I realize that all these variations on syntax can be somewhat confusing, especially if you are new to TiddlyWiki scripting… but I promise you that once you get some familiarity with them, it will become second nature and the “syntax guessing game” will be a thing of the past.
Hope this helps. Let me know how it goes…
enjoy,
-e