Variable in fields:include[ ]?

as an extension of http://inmysocks.tiddlyspot.com “Search all fields by content” I want to restrict the selection of fields by checkbox. So I end up with the following code:

\define searchInField(field, for)
<$list filter="[tag[mpi]!is[shadow]!is[system]field:$field$/$for$/]"> ‘’ $field$:’’ <$view field=$field$/> in <$link><$view field=“title”/></$link>

    \end

    <$checkbox field=“ort” checked=“ort” unchecked="" default=“ort”> Ort?
    <$checkbox field=“wert” checked=“wert” unchecked="" default=“wert”> Wert
    </$checkbox>


    Suche: <$edit-text tiddler=’$:/temp/temp’ field=‘test_search’/>

    <$list filter="[tag[mpi]!is[shadow]!is[system]fields:include[ ort wert ]] -title -text -tags" variable=“fieldname”>
    <$macrocall $name=“searchInField” field=<> for={{$:/temp/temp!!test_search}}/>
    </$list>

    But how do I replace in “fields:include[ ort wert ]]” ort and wert with the fields? {{!!ort}} does not work unfortunately.

    In filters you can’t use use transclusion (or variables/macros) like in the (normal) text. (See the part of “Special parameters” in https://tiddlywiki.com/#Introduction%20to%20filter%20notation )

    You have to use in your filter this {!!ort} instead of {{!!ort}}

    Thanks for the answer.
    But {!!ort} doesn’t work. I tried also many other variant’s, i found nothing that works in :include[].

    There was a lot that needed tweaking. I don’t know if Discourse did it, or the editor you were using, or your keyboard, but there were quote mark mismatches that usually only occur if you’re using something like Word. They had to be replaced everywhere. I’ve never seen the syntax /$for$/ for field, so assume Jed is using his own field filter. There were also mismatched widget tags.

    This worked for me though lightly tested. Keep in mind that you need to initialize your checkboxes once in order to create the fields (i.e. check them on and off once).

    \define searchInField(field, for)
    <$list filter="[tag[mpi]!is[shadow]!is[system]field:$field$[$for$]]"> ''$field$'': <$view field=$field$/> in <$link><$view field="title"/></$link><br/>
    </$list>
    \end
    <$checkbox field="ort" checked="ort" unchecked="" default="ort"> Ort? </$checkbox>
    <$checkbox field="wert" checked="wert" unchecked="" default="wert"> Wert </$checkbox>
    
    Suche: <$edit-text tiddler="$:/temp/temp" field="test_search"/>
    
    <$vars include={{{ [{!!ort}addsuffix[ ]addsuffix{!!wert}]}}}>
    <$list filter="[tag[mpi]!is[shadow]!is[system]fields:include<include>]" variable="fieldname">
    <$macrocall $name="searchInField" field=<<fieldname>> for={{$:/temp/temp!!test_search}}/>
    </$list>
    </$vars>
    

    Thank you, this works! :slight_smile:

    I did the code direct copy from the tiddler, running in Tiddlydesktop under linux. I can not see a problem with quote mark. ??

    Ok, importend for me ist the “include” note.
    Thank’s.

    Hi, My field-search plugin may be an option here too. It has a configuration tab in the ControlPanel and a short intro video, to see what’s possible.

    These quotes don’t match: “ort”

    Apparently Discourse changes straight quotes “hi there” to “hi there” when you use the quote mechanism. I didn’t know that when I copied your code.

    Thanks!

    Besides the tabular listing I want to use the result in leafmap, to show only the result.

    <$leafmap places=’{“filter”:"[tag[mpi]]"}’>

    What is the best way to get the listing into this leafmap?

    thanks, but I think that would be too complicated for me. :wink:

    Aber gut zu wissen das es deutschsprachige User hier gibt die sich gut auskennen. :slight_smile:

    Thanks

    1 Like

    It’s actually an example of an old but now deprecated syntax for expressing the operand of a filter as a regular expression:

    [field/bo+k/]
    

    The problem with the syntax is that individual operators have to be aware of and handle the possibility of a regexp operand themselves. We only got as far as implementing it for the “field” operator before realising that it was a dead end, and introducing the “regexp” operator instead.