head	1.9;
access;
symbols;
locks
	nobody:1.9; strict;
comment	@# @;


1.9
date	2002.08.13.16.46.44;	author PeterThoeny;	state Exp;
branches;
next	1.8;

1.8
date	2002.05.17.06.57.28;	author PeterThoeny;	state Exp;
branches;
next	1.7;

1.7
date	2002.04.20.02.37.00;	author PeterThoeny;	state Exp;
branches;
next	1.6;

1.6
date	2002.02.18.06.22.45;	author PeterThoeny;	state Exp;
branches;
next	1.5;

1.5
date	2002.02.16.19.13.13;	author PeterThoeny;	state Exp;
branches;
next	1.4;

1.4
date	2002.01.15.06.14.17;	author PeterThoeny;	state Exp;
branches;
next	1.3;

1.3
date	2001.12.02.12.33.20;	author MikeMannix;	state Exp;
branches;
next	1.2;

1.2
date	2001.11.29.07.02.46;	author PeterThoeny;	state Exp;
branches;
next	1.1;

1.1
date	2001.10.25.02.13.01;	author PeterThoeny;	state Exp;
branches;
next	;


desc
@none
@


1.9
log
@none
@
text
@%META:TOPICINFO{author="PeterThoeny" date="1029257204" format="1.0" version="1.9"}%
%META:TOPICPARENT{name="TWikiVariables"}%
%TOC%
%STARTINCLUDE%
---# TWiki Formatted Search Results

_Inline search feature allows flexible formatting of search result_

The =%<nop>SEARCH{...}%= variable documented in TWikiVariables has a fixed format for the search result, that is, a table consisting of topic names and topic summaries. Use the =format="..."= parameter to specify a customized format of the search result. The string of the format parameter is typically a bullet list or table row containing variables (such as =%<nop>SEARCH{ "food" format="| $topic | $summary |" }%=).

---++ Syntax

Two parameters can be used to specify a customized search result:

1. =header="..."= parameter

Use the header parameter to specify the header of a search result. It should correspond to the format of the format parameter. This parameter is optional. <br /> Example: =header="| <nop>*Topic:*<nop> | <nop>*Summary:*<nop> |"=

2. =format="..."= parameter

Use the format parameter to specify the format of one search hit.
<br /> Example: =format="| $topic | $summary |"=

Variables that can be used in the format string:

| *Name:* | *Expands To:* |
| =$web= | Name of the web |
| =$topic= | Topic name |
| =$topic(20)= | Topic name, "<tt>- </tt>" hyphenated each 20 characters |
| =$topic(30, -&lt;br /&gt;)= | Topic name, hyphenated each 30 characters with separator "<tt>-&lt;br /&gt;</tt>" |
| =$topic(40, ...)= | Topic name, shortended to 40 characters with "<tt>...</tt>" indication |
| =$text= | Formatted topic text |
| =$locked= | LOCKED flag (if any) |
| =$date= | Time stamp of last topic update, like =%GMTIME{"$day $mon $year - $hour:$min"}%= |
| =$isodate= | Time stamp of last topic update, like =%GMTIME{"$year-$mo-$dayT$hour:$minZ"}%= |
| =$rev= | Number of last topic revision, like =1.4= |
| =$wikiusername= | Wiki user name of last topic update, like =%MAINWEB%.<nop>JohnSmith= |
| =$username= | User name of last topic update, like =<nop>JohnSmith= |
| =$summary= | Topic summary |
| =$formfield(name)= | The field value of a form field; for example, =$formfield(<nop>TopicClassification)= would get expanded to =PublicFAQ=. This applies only to topics that have a [[TWikiForms][TWikiForm]] |
| =$formfield(name, 10)= | Form field value, "<tt>- </tt>" hyphenated each 10 characters |
| =$formfield(name, 20, -&lt;br /&gt;)= | Form field value, hyphenated each 20 characters with separator "<tt>-&lt;br /&gt;</tt>" |
| =$formfield(name, 30, ...)= | Form field value, shortended to 30 characters with "<tt>...</tt>" indication |
| =$pattern(reg-exp)= | A regular expression pattern to extract some text from a topic. For example, =$pattern(.*?\*.*?Email\:\s*([^\n\r]+).*)= extracts the email address from a bullet of format =* Email: ...=. |
| =$n= or =$n()= | New line |
| =$nop= or =$nop()= | Is a "no operation". This variable gets removed; useful for nested search |
| =$quot= | Double quote (="=). Alternatively write =\"= to escape it |
| =$percnt= | Percent sign (=%=) |
| =$dollar= | Dollar sign (=$=) |

__Note:__ For =$pattern(reg-exp)=, specify a RegularExpression that scans from start to end and contains the text you want to keep in parenthesis, like =$pattern(.*?(from here.*?to here).*)=. You need to make sure that the integrity of a web page is not compromised; for example, if you include a table make sure to include everything including the table end tag.


---++ Examples


#SearchBulletList
---+++ Bullet list showing topic name and summary

*Write this:*

=%<nop>SEARCH{ "FAQ" scope="topic" nosearch="on" nototal="on" header="	* <nop>*Topic: Summary:*" format="	* [<nop>[$topic]]: $summary" }%=

*To get this:*

%SEARCH{ "FAQ" scope="topic" nosearch="on" nototal="on" header="	* *Topic: Summary:*" format="	* [[$topic]]: $summary" }%


---+++ Table showing form field values of topics with a form

*Write this in the Know web:*

=| <nop>*Topic:*<nop> | <nop>*<nop>OperatingSystem:*<nop> | <nop>*<nop>OsVersion:*<nop> |= <br />
=%<nop>SEARCH{ "[T]opicClassification.*?value=\"[P]ublicFAQ\"" scope="text" regex="on" nosearch="on" nototal="on" format="| [<nop>[$topic]] | $formfield(<nop>OperatingSystem) | $formfield(<nop>OsVersion) |" }%=

*To get this:*

<table border="1" cellspacing="0" cellpadding="1">
<tr>
 <th bgcolor="#99CCCC"> <strong>Topic:</strong> </th>
 <th bgcolor="#99CCCC"> <strong>OperatingSystem:</strong> </th>
 <th bgcolor="#99CCCC"> <strong>OsVersion:</strong> </th></tr>
<tr>
 <td>  <a href="%SCRIPTURLPATH%/view%SCRIPTSUFFIX%/Know/IncorrectDllVersionW32PTH10DLL">IncorrectDllVersionW32PTH10DLL</a>  </td><td>  <a href="%SCRIPTURLPATH%/view%SCRIPTSUFFIX%/Know/OsWin">OsWin</a>  </td><td>  95/98  </td></tr>
<tr>
 <td>  <a href="%SCRIPTURLPATH%/view%SCRIPTSUFFIX%/Know/WinDoze95Crash">WinDoze95Crash</a>  </td>
 <td>  <a href="%SCRIPTURLPATH%/view%SCRIPTSUFFIX%/Know/OsWin">OsWin</a>  </td>
 <td>  95  </td></tr>
</table>


---+++ Extract some text from a topic using regular expression

*Write this:*

=%<nop>SEARCH{ "__Back to\:__ <nop>TWikiFAQ" scope="text" regex="on" nosearch="on" nototal="on" header="TWiki FAQs:" format="	* $pattern(.*?FAQ\:[\n\r]*([^\n\r]+).*) [<nop>[$topic][Answer...]]" }%=

*To get this:*

%SEARCH{ "__Back to\:__ TWikiFAQ" scope="text" regex="on" nosearch="on" nototal="on" header="TWiki FAQs:" format="	* $pattern(.*?FAQ\:[\n\r]*([^\n\r]+).*) [[$topic][Answer...]]" }%


---+++ Nested Search

Search can be nested. For example, search for some topics, then form a new search for each topic found in the first search. The idea is to build the nested search string using a formatted search in the first search.

Here is an example. Let's search for all topics that contain the word "culture" (first search), and let's find out where each topic found is linked from (second search).

	* First search:
		* =%<nop>SEARCH{ "culture" format="	* $topic is referenced by: (list all references)" nosearch="on" nototal="on" }%=
	* Second search. For each hit we want this search:
		* =%<nop>SEARCH{ "(topic found in first search)" format="	$topic" nosearch="on" nototal="on" }%=
	* Now let's nest the two. We need to escape the second search, e.g. the first search will build a valid second search string. Note that we escape the second search so that it does not get evaluated prematurely by the first search:
		* Use =$percnt= to escape the leading percent of the second search
		* Use =\"= to escape the double quotes
		* Use =$dollar= to escape the =$= of =$topic=
		* Use =$nop= to escape the =}%= sequence

*Write this:*

=%<nop>SEARCH{ "culture" format="	* $topic is referenced by:$n		* $percntSEARCH{ \"$topic\" format=\"	$dollartopic\" nosearch=\"on\" nototal=\"on\" }$nop%" nosearch="on" nototal="on" }%=

*To get this:*

%SEARCH{ "culture" format="	* $topic is referenced by:$n		* $percntSEARCH{ \"$topic\" format=\"	$dollartopic\" nosearch=\"on\" nototal=\"on\" }$nop%" nosearch="on" nototal="on" }%


-- Main.PeterThoeny - 16 May 2002
@


1.8
log
@none
@
text
@d1 1
a1 1
%META:TOPICINFO{author="PeterThoeny" date="1021618648" format="1.0" version="1.8"}%
d17 1
a17 1
Use the header paramter to specify the header of a search result. It should correspond to the format of the format parameter. This parameter is optional. <br /> Example: =header="| <nop>*Topic:*<nop> | <nop>*Summary:*<nop> |"=
@


1.7
log
@none
@
text
@d1 1
a1 1
%META:TOPICINFO{author="PeterThoeny" date="1019270220" format="1.0" version="1.7"}%
a52 1
---++ Nested Search
d54 1
a54 17
Search can be nested. For example, search for some topics, then form a new search for each topic found in the first search. The idea is to build the nested search string using a formatted search in the first search.

Here is an example. We want to search for topics, do a nested search with each hit, and show the result as nested bullets. Parameters like =scope="text" regex="on" nosearch="on" nototal="on"= are omitted for simplicity.

	* First search:
		* =%<nop>SEARCH{ "freedom" format="	* $topic" }%=
	* Second search. For each hit we want this search:
		* =%<nop>SEARCH{ "(topic of first search)" format="		* $topic" }%=
	* Now we nest the searches. We need to escape the second search, e.g. the first search will build a valid second search string:
		* =%<nop>SEARCH{ "freedom" format="	* $topic: $n$percntSEARCH{ \"$topic\" format=\"		* $dollartopic" }$nop%\" }%=

Note that we escape the second search so that it does not get evaluated by the first search:

	* =$percnt= to escape the leading percent of the second search
	* =\"= to escape the qouble quotes
	* =$dollar= to escape the =$= of =$topic=
	* =$nop= to escape the =}%= sequence
a56 2
---++ Examples

d60 1
a60 1
Write this:
d64 1
a64 1
To get this:
d68 1
d71 1
a71 1
Write this in the Know web:
d76 1
a76 1
To get this:
d91 1
d94 1
a94 1
Write this:
d98 1
a98 1
To get this:
d101 26
@


1.6
log
@none
@
text
@d1 1
a1 1
%META:TOPICINFO{author="PeterThoeny" date="1014013365" format="1.0" version="1.6"}%
a8 2
---++ Overview

d13 1
a13 1
Two paramters can be used to specify a customized search result:
d17 1
a17 1
Use the header paramter to specify the header of a search result. It should correspond to the format of the format parameter. This parameter is optional. I.e. <br /> =header="| <nop>*Topic:*<nop> | <nop>*Summary:*<nop> |"=
d21 2
a22 1
Use the format paramter to specify the format of one search hit. I.e. <br /> =format="| $topic | $summary |"=
a26 1
| =$n= | New line |
d29 3
d34 5
a38 5
| =$date= | Time stamp of last topic update, i.e. =%GMTIME{"$day $mon $year - $hour:$min"}%= |
| =$isodate= | Time stamp of last topic update, i.e. =%GMTIME{"$year-$mo-$dayT$hour:$minZ"}%= |
| =$rev= | Number of last topic revision, i.e. =1.4= |
| =$wikiusername= | Wiki user name of last topic update, i.e. =%MAINWEB%.<nop>JohnSmith= |
| =$username= | User name of last topic update, i.e. =<nop>JohnSmith= |
d40 32
a71 2
| =$formfield(name)= | The field value of a form field, i.e. =$formfield(<nop>TopicClassification)= would get expanded to =PublicFAQ=. This applies only to topics that have a [[TWikiForms][TWikiForm]] |
| =$pattern(reg-exp)= | A regular expression pattern to extract some text from a topic, i.e. =$pattern(.*?\*.*?Email\:\s*([^\n\r]+).*)= extracts the email address from a bullet of format =* Email: ...=. |
a72 1
__Note:__ For =$pattern(reg-exp)=, specify a RegularExpression that scans from start to end and contains the text you want to keep in parenthesis, i.e. =$pattern(.*?(from here.*?to here).*)=. You need to make sure that the integrity of a web page is not compromised, i.e. if you include a table make sure to include everything including the table end tag.
d76 1
d119 1
a119 1
-- Main.PeterThoeny - 28 Nov 2001 <br />
@


1.5
log
@none
@
text
@d1 1
a1 1
%META:TOPICINFO{author="PeterThoeny" date="1013886793" format="1.0" version="1.5"}%
d31 1
a31 1
| =$topictext= | Formatted topic text |
@


1.4
log
@none
@
text
@d1 1
a1 1
%META:TOPICINFO{author="PeterThoeny" date="1011075257" format="1.0" version="1.4"}%
d31 1
@


1.3
log
@none
@
text
@d1 1
a1 1
%META:TOPICINFO{author="MikeMannix" date="1007296400" format="1.0" version="1.3"}%
d11 1
a11 1
By default, the format for displaying a search result is fixed, e.g. a table with rows of topic name and topic summary. Use the =format="..."= parameter to specify a customized format of the search result. The string of the format parameter is typically a bullet list or table row containing variables (i.e. =%<nop>SEARCH{ "food" format="| $topic | $summary |" }%=).
@


1.2
log
@none
@
text
@d1 1
a1 1
%META:TOPICINFO{author="PeterThoeny" date="1007018373" format="1.0" version="1.2"}%
d3 3
a5 1
*Formatted Search Using ==%<nop>SEARCH{... format="..."}%== Variable*
d7 1
a7 1
%TOC%
d9 1
a9 1
---++ Preface
@


1.1
log
@none
@
text
@d1 1
a1 1
%META:TOPICINFO{author="PeterThoeny" date="1003975981" format="1.0" version="1.1"}%
d17 1
a17 1
Use the header paramter to specify the header of a search result. It should correspond to the format of the format parameter. This parameter is optional. I.e. =header="| <nop>*Topic:*<nop> | <nop>*Summary:*<nop> |"=
d21 1
a21 1
Use the format paramter to specify the format of one search hit. I.e. =format="| $topic | $summary |"=
d26 1
d30 2
a31 1
| =$date= | Time stamp of last topic update |
d34 1
d36 1
a36 1
| =$formfield(name)= | The field value of a form field, i.e. =$formfield(TopicClassification)= would get expanded to =PublicFAQ=. This applies only to topics that have a [[TWikiForms][TWikiForm]] |
d58 1
a58 1
=%<nop>SEARCH{ "[T]opicClassification.*?value=\"[P]ublicFAQ\"" scope="text" regex="on" nosearch="on" nototal="on" format="| [<nop>[$topic]] | $formfield(OperatingSystem) | $formfield(OsVersion) |" }%=
d85 1
a85 1
-- Main.PeterThoeny - 24 Oct 2001 <br />
@
