How to pass content of a field to the filter?

Greetings to the TW Community

I would like to make a filter which use a content of a field (subcat) in the filter, but I can’t seem to find the correct syntax.

First unsuccessful attempt:

<$list filter="[!is[system]sort[caption]] +[contains:subcat[{{!!subcat}}]]">

I tested to declare a variable but nothing works:

<$set name=myvar a value={{!!subcat}}>
<$list filter="[!is[system]sort[caption]] +[contains:subcat$[$myvar$]]">
or 
<$list filter="[!is[system]sort[caption]] +[contains:subcat[{{myvar}}]]">
or
<$list filter="[!is[system]sort[caption]] +[contains:subcat[<<myvar>>]]">

Can you help me find what’s wrong?

Have a good day!

In filter syntax, the brackets surrounding a filter operand indicate how that operand is interpreted:

  • square brackets enclose literal text values (e.g., [sometext])
  • angle brackets enclose variable names (e.g., <somevariable>)
  • curly brackets enclose tiddler field references (e.g., {!!somefield})

Also note that within filter syntax, unlike wikitext or widget syntax, the brackets surrounding a filter operand are not doubled.

Thus, your desired filter syntax should be:

<$list filter="[!is[system]sort[caption]] +[contains:subcat{!!subcat}]">

or, if you want to use a variable:

<$let myvar={{!!subcat}}>
<$list filter="[!is[system]sort[caption]] +[contains:subcat<myvar>]">
</$let>

enjoy,
-e

7 Likes

Thank you Eric, you’ve helped me once again and thank you too for the explanations!