is there any method to link text to the filter search result?

106 views
Skip to first unread message

yrosgi L

unread,
May 15, 2020, 3:21:34 AM5/15/20
to TiddlyWiki
For example, there is a query text "[tag[todo]]" in a tiddler.
What it should link to is the search page (like "$:/core/ui/AdvancedSearch/Filter") but listed the result of the query text.

Personally I think it is impossible because I haven't find a way to pass the value to the search page.
And now I just link to a tiddler that manually provide the result.

Thanks in advance.

Eric Shulman

unread,
May 15, 2020, 4:20:16 AM5/15/20
to tiddl...@googlegroups.com
It is actually relatively easy to do.  Start by creating the following macro definition (in a tiddler tagged with $:/tags/Macro):
\define filtersearch(filter)
<$button class="tc-btn-invisible">
<$text text="""$filter$""" />
<$action-navigate $to="$:/AdvancedSearch"/>
<$action-setfield $tiddler="$:/state/tab--1498284803" text="$:/core/ui/AdvancedSearch/Filter" />
<$action-setfield $tiddler="$:/temp/advancedsearch" text="""$filter$""" />
</$button>
\end

What it does:
* pass the desired filter syntax as a macro parameter
* create a button that displays the filter as normal text (no border/background)
* this button performs three actions:
   1) open the $:/AdvancedSearch tiddler
   2) select the "Filter" tab by setting the text of $:/state/tab--1498284803 to $:/core/ui/AdvancedSearch/Filter
   3) set the text of $:/temp/advancedsearch to search for the desired filter syntax

To call the "filtersearch" macro from within your content, write something like:
This is some text to search for <<filtersearch "[tag[todo]]">> within this document

Note:
Step 2 references a specific "$:/state/tab" tiddler that includes a unique "magic number" which is generated by the <<qualify>> macro (see https://tiddlywiki.com/#qualify%20Macro).  I found the appropriate $:/state/tab tiddler by using the AdvancedSearch/Filter tab to search for "[prefix[$:/state/tab]text[$:/core/ui/AdvancedSearch/Filter]]".  This magic number should be the same for all TiddlyWiki documents that use the standard shadow definition for the $:/AdvancedSearch tiddler.

enjoy,
-e
Eric Shulman
TiddlyTools.com: "Small Tools for Big Ideas!" (tm)

yrosgi L

unread,
May 15, 2020, 11:02:41 AM5/15/20
to TiddlyWiki
Thank you, Eric! It looks like a magic.

在 2020年5月15日星期五 UTC+8下午4:20:16,Eric Shulman写道:

Sylvain Naudin

unread,
May 15, 2020, 4:30:24 PM5/15/20
to TiddlyWiki
Thank you Eric, always very instructive answers!

Sylvain
Reply all
Reply to author
Forward
0 new messages