\define field() temp/search/field
\define term() temp/search/term
\define flag() temp/search/flag
\define searchTerm() {{$(term)$!!text}}
<$list filter="[tag[xx]search:{$(field)$}:{$(flag)$}[$(searchTerm)$]]">
</$list>
\define tidinput() $:/temp/search/tid
\define taginput() $:/temp/search/tag
\define fieldinput() $:/temp/search/field
\define terminput() $:/temp/search/term
\define flaginput() $:/temp/search/flag
\define doSearch()
<$vars filter="""[all[$(tids)$]tag:strict[$(tag)$]search:$(field)$:$(flag)$[$(term)$]]""">
There are <$count filter=<<filter>>/> tiddlers matching ''<$text text=<<filter>>/>''
<blockquote>
@@.columns3.small <$list filter=<<filter>>><$link/><br></$list>@@
</blockquote>
</$vars>
\end
| tiddlers to search:|<$edit-text tiddler=<<tidinput>> tag="input" default="" placeholder="tiddlers" />|
| tag for search:|<$edit-text tiddler=<<taginput>> tag="input" default="" placeholder="enter a tag" />|
| field(s) for search (comma-separated field names):|<$edit-text tiddler=<<fieldinput>> tag="input" default="" placeholder="title,text,tags" />|
| flag(s) for search (comma-separated keywords):|<$edit-text tiddler=<<flaginput>> tag="input" default="" placeholder="words" />|
| text to search for:|<$edit-text tiddler=<<terminput>> tag="input" default="" placeholder="enter search text" />|
<$vars
tids={{{ [<tidinput>get[text]] ~[[tiddlers]] }}}
tag={{{ [<taginput>get[text]] }}}
field={{{ [<fieldinput>get[text]] ~[[title,text,tags]] }}}
flag={{{ [<flaginput>get[text]] ~[[words]] }}}
term={{{ [<terminput>get[text]] }}}>
<<doSearch>>
</$vars>
On Wednesday, December 11, 2019 at 9:59:39 PM UTC-8, Mohammad wrote:Search operator https://tiddlywiki.com/prerelease/#search%20Operatorhas flag list, field list and operand! I want to have a list widget and search through some tiddlers pragmatically!so everything is a variable!field: transcluded from temp/search/fieldterm: transcluded from temp/search/termflag: transcluded from temp/search/flagso for example
\define field() temp/search/field
\define term() temp/search/term
\define flag() temp/search/flag
\define searchTerm() {{$(term)$!!text}}
<$list filter="[tag[xx]search:{$(field)$}:{$(flag)$}[$(searchTerm)$]]">
</$list>no success, I know something wrong with variables
There are two problems with your example code:1) you can't use the $(variable)$ syntax unless you are within a macro
2) The [search:field:flags[...]] filter can't use transclusion for substitution in the field and flags part of the syntax.
Also,3) If you don't provide a tag value, it won't match anything. To avoid this, use the tag:strict[...] filter syntax
4) You haven't provided any control over what kinds of tiddlers to search. To add this, put an all[...] filter at the beginning
Here's my solution, which I have uploaded to http://tiddlytools.com/filtergenerators.html
enjoy,-e
On Thursday, December 12, 2019 at 11:04:09 AM UTC+3:30, Eric Shulman wrote:3) If you don't provide a tag value, it won't match anything. To avoid this, use the tag:strict[...] filter syntaxI do not understand this quite well! I have seen this before in https://tiddlywiki.com/prerelease/#tag%20Operatorwhat really strict does mean here?
4) You haven't provided any control over what kinds of tiddlers to search. To add this, put an all[...] filter at the beginningIsn't it it assume all[tiddlers] ?
Here's my solution, which I have uploaded to http://tiddlytools.com/filtergenerators.htmlThis is great! A one place for filter solution and for later use! a codepen like for Tiddlywiki (live experimenting)I will email David to add to tiddlywiki toolmap!
Comments:
- I understand $var widget has filter input parameter, not documented and I always use set for this purpose
- I should be able to use regexp as search flag and this will give higher flexibility
Thanks again! Every answer like this is small lesson in wikitext scripting.
The http://tiddlytools.com/filtergenerators.html site title is good to change to reflect the purpose like Filter Generator.
enjoy,-e
A design pattern I use to simplify similar code is turning text references or transcludes into variables
\define sitetitle() {{$:/SiteTitle}}
\define sitesubtitle() {{$:/SiteSubtitle}}
These can be global variables as well
One advantage being variables can be reset with a local variable or field.
<$set name=sitetitle value={{!!sitetitle-field}} emptyValue=<<sitetitle>> >
Note how the new value can be sourced anywhere and you can even reuse the variable name, which is a kind of override.
This method allows fields, tiddlers and text references to become variables, All that is missing is the ability to allow variables to become fields, tiddlers and text references without a trigger button. Since the view widget does not accept variable input we have a serious gap. I plan to make a workaround soon.
Regards
Tony