[tw5] Re: is there any method to link text to the filter search result?

2020-05-15 Thread Sylvain Naudin
Thank you Eric, always very instructive answers!

Sylvain

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/bece96c8-4ee6-483a-95d0-3b4ca766d908%40googlegroups.com.


[tw5] Re: is there any method to link text to the filter search result?

2020-05-15 Thread yrosgi L
Thank you, Eric! It looks like a magic. 

在 2020年5月15日星期五 UTC+8下午4:20:16,Eric Shulman写道:
>
> On Friday, May 15, 2020 at 12:21:34 AM UTC-7, yrosgi L wrote:
>>
>> 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.
>>
>
> 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$""" />
> 
> \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 <> within this 
> document
>
> Note:
> Step 2 references a specific "$:/state/tab" tiddler that includes a unique 
> "magic number" which is generated by the <> 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)
> InsideTiddlyWiki - http://TiddlyTools.com/InsideTW
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/cfdba44d-9e00-45c3-8c49-e522d5fd7a2a%40googlegroups.com.


[tw5] Re: is there any method to link text to the filter search result?

2020-05-15 Thread Eric Shulman
On Friday, May 15, 2020 at 12:21:34 AM UTC-7, yrosgi L wrote:
>
> 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.
>

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$""" />

\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 <> within this 
document

Note:
Step 2 references a specific "$:/state/tab" tiddler that includes a unique 
"magic number" which is generated by the <> 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)
InsideTiddlyWiki - http://TiddlyTools.com/InsideTW

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/2fd09434-dff2-421f-ac5b-ae37c7dbc867%40googlegroups.com.