Field value against list of tags

HI,

i am trying to display a message if a value in a user defined field matches the current tags in a tiddler , so one value in a field against multiple tag values in the same tiddler , what am i doing wrong here

thank you

 <$let testvariable={{{[<currentTiddler>get[field1]]}}}>
 <$let testvariable2={{{[<currentTiddler>tags[]]}}}>
 
<$list filter="[<thisvariable>match<testvariable2>]" emptyMessage= "matches"> doesnt match</$list>

Try this:

<$let testvariable={{{ [<currentTiddler>get[field1]] }}}>
<$let testvariable2={{{ [<currentTiddler>get[tags]] }}}>

<$list filter="[enlist<testvariable2>match<testvariable>]" emptyMessage="doesn't match"> matches </$list>
<$list filter="[<currentTiddler>contains:tags<testvariable>]" emptyMessage= "doesn't match"> matches</$list>

Notes:

  1. In your posted code, you assign to testvariable, but the filter refers to thisvariable
  2. In your 2nd $let widget, you used {{{ [<currentTiddler>tags[]] }}}, which could contain a list of tag values. However, when a “filtered transclusion” is used to set a value of a widget parameter, only the value of the first item in the filter results will be assigned to the parameter.
  3. In my example code, the 2nd $let widget uses {{{ [<currentTiddler>get[tags]] }}}, which gets the tags field value as a single text string composed of space-separated tag values. Then, in the $list widget, we use enlist<testvariable2> to “unpack” the text string into separate items to look for a match with <testvariable>
  4. In my example code, the 2nd $list widget demonstrate the use of the contains:tags... filter operator, which implicitly searches the currentTiddler’s list of tags for a matching value, without needing to directly retrieve the tags field value into testvariable2.

enjoy,
-e

2 Likes

Thank you Eric

this was very clear

Maybe

{{{ [enlist{!!tags}match{!!field1}then[match]else[nope]] }}}

1 Like