List filter using tag selected by Radio Button

I’ve been trying to create a list filter with a tag selected using a Radio Button. I started with some code that worked to select tiddlers with Radio Button selected field contents, but now I want to use tags instead. I’ve search several resources to find examples for this but have not found any yet.

<$radio tiddler="$:/temp/sev" value="high">&nbsp;High</$radio>;
<$radio tiddler="$:/temp/sev" value="medium">&nbsp;Medium</$radio>;
<$radio tiddler="$:/temp/sev" value="low">&nbsp;Low</$radio>;

<$list filter="[!has[draft.of]tag[{$:/temp/sev}]]">

If I replace {$:/temp/sev} with the actual tag, I get the expected list of tiddlers.
So my guess is I don’t understand what syntax is required within the tag square brackets or I didn’t properly define $:/temp/sev or maybe both.

Thanks to all who give it a look.

The type of brackets depends upon the type of filter operand:

  • Square brackets indicate a literal text parameter
    operator[text]
    Curly braces indicate a tiddler field reference
    operator{tiddlertitle} or operator{!!fieldname} or operator{tiddlertitle!!fieldname}
    Angle brackets indicate a variable or macro
    operator<var> or operator<macro> or operator<macro param param...>

Thus, for your usage:
<$list filter="[tag{$:/temp/sev}!has[draft.of]]">

Note also that filter processing is more efficient if you apply the tag{$:/temp/sev} filter before the !has[draft.of] filter. This is because

  • the tag operator is highly optimized. The TWCore uses an internally-cached tag index to dramaticaly reduce processing overhead after the first tag filter is processed. The internal tag index is only re-indexed if a tiddler’s fields are changed.
  • The !has operator then only needs to examine the draft.of fields for tiddlers that have matched the specified tag value, instead of examining the draft.of field for ALL tiddlers.

enjoy,
-e

2 Likes

Perfect explanation
Perfect result

Thanks Eric