| |||||||||||
Line: 6 to 6 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Inline search feature allows flexible formatting of search result | |||||||||||
Changed: | |||||||||||
< < |
The %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 %SEARCH{ "food" format="| $topic | $summary |" }% ).
| ||||||||||
> > |
The %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 %SEARCH{ "food" format="| $topic | $summary |" }% ).
| ||||||||||
Syntax | |||||||||||
Line: 29 to 29 | |||||||||||
| |||||||||||
Added: | |||||||||||
> > |
| ||||||||||
| |||||||||||
Line: 47 to 49 | |||||||||||
| |||||||||||
Changed: | |||||||||||
< < |
| ||||||||||
> > |
| ||||||||||
| |||||||||||
Deleted: | |||||||||||
< < |
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 | |||||||||||
Line: 74 to 74 | |||||||||||
Table showing form field values of topics with a form | |||||||||||
Changed: | |||||||||||
< < |
Write this in the Know web: | ||||||||||
> > |
In a web where there is a form that contains a TopicClassification field, an OperatingSystem field and an OsVersion field we could write:
| ||||||||||
| *Topic:* | *OperatingSystem:* | *OsVersion:* | %SEARCH{ "[T]opicClassification.*?value=\"[P]ublicFAQ\"" scope="text" regex="on" nosearch="on" nototal="on" format="| [[$topic]] | $formfield(OperatingSystem) | $formfield(OsVersion) |" }%
| |||||||||||
Changed: | |||||||||||
< < |
To get this: | ||||||||||
> > |
To get this: | ||||||||||
| |||||||||||
Line: 87 to 87 | |||||||||||
| |||||||||||
Changed: | |||||||||||
< < |
| ||||||||||
> > |
| ||||||||||
Changed: | |||||||||||
< < |
| ||||||||||
> > |
| ||||||||||
| |||||||||||
Line: 130 to 130 | |||||||||||
| |||||||||||
Added: | |||||||||||
> > |
Note: Nested search can be slow, especially if you nest more then 3 times. Nesting is limited to 16 levels. For each new nesting level you need to "escape the escapes", e.g. write $dollarpercntSEARCH{ for level three, $dollardollarpercntSEARCH{ for level four, etc.
| ||||||||||
Most recently changed pagesWrite this: | |||||||||||
Line: 192 to 194 | |||||||||||
Result: Number of topics: 0 | |||||||||||
Changed: | |||||||||||
< < |
-- TWiki:Main.PeterThoeny - 16 Mar 2004 | ||||||||||
> > |
-- TWiki:Main.PeterThoeny - 26 Jul 2004 | ||||||||||
| ||||||||||||||||||||||
Line: 140 to 140 | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||
Added: | ||||||||||||||||||||||
> > |
Search with conditional outputA regular expression search is flexible, but there are limitations. For example, you cannot show all topics that are up to exactly one week old, or create a report that shows all records with invalid form fields or fields within a certain range, etc. You need some additional logic to format output based on a condition:
%CALC{$SET(weekold, $TIMEADD($TIME(), -7, day))}% %SEARCH{ "." scope="topic" regex="on" nosearch="on" nototal="on" order="modified" reverse="on" format="$percntCALC{$IF($TIME($date) < $GET(weekold), <nop>, | [[$topic]] | $wikiusername | $date | $rev |)}$percnt" limit="100" }%
| |||||||||||||||||||||
Embedding search forms to return a formatted resultUse an HTML form and an embedded formatted search on the same topic. You can link them together with an%URLPARAM{"..."}% variable. Example:
|
| ||||||||||||||||||||||
Line: 24 to 24 | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Variables that can be used in the format string:
| ||||||||||||||||||||||
Changed: | ||||||||||||||||||||||
< < |
| |||||||||||||||||||||
> > |
| |||||||||||||||||||||
| ||||||||||||||||||||||
Changed: | ||||||||||||||||||||||
< < |
| |||||||||||||||||||||
> > |
| |||||||||||||||||||||
| ||||||||||||||||||||||
Added: | ||||||||||||||||||||||
> > |
| |||||||||||||||||||||
| ||||||||||||||||||||||
Added: | ||||||||||||||||||||||
> > |
| |||||||||||||||||||||
| ||||||||||||||||||||||
Changed: | ||||||||||||||||||||||
< < |
| |||||||||||||||||||||
> > |
| |||||||||||||||||||||
| ||||||||||||||||||||||
Line: 110 to 115 | ||||||||||||||||||||||
| ||||||||||||||||||||||
Changed: | ||||||||||||||||||||||
< < |
| |||||||||||||||||||||
> > |
| |||||||||||||||||||||
| ||||||||||||||||||||||
Line: 119 to 124 | ||||||||||||||||||||||
Write this: | ||||||||||||||||||||||
Changed: | ||||||||||||||||||||||
< < |
%SEARCH{ "culture" format=" * $topic is referenced by:$n * $percntSEARCH{ \"$topic\" format=\" $dollartopic\" nosearch=\"on\" nototal=\"on\" }$nop%" nosearch="on" nototal="on" }%
| |||||||||||||||||||||
> > |
%SEARCH{ "culture" format=" * $topic is referenced by:$n * $percntSEARCH{ \"$topic\" format=\"$dollartopic\" nosearch=\"on\" nototal=\"on\" separator=\", \" }$nop%" nosearch="on" nototal="on" }%
| |||||||||||||||||||||
To get this: | ||||||||||||||||||||||
Changed: | ||||||||||||||||||||||
< < |
| |||||||||||||||||||||
> > |
| |||||||||||||||||||||
Most recently changed pages | ||||||||||||||||||||||
Line: 135 to 140 | ||||||||||||||||||||||
| ||||||||||||||||||||||
Changed: | ||||||||||||||||||||||
< < |
-- TWiki:Main.PeterThoeny - 15 Dec 2003 | |||||||||||||||||||||
> > |
Embedding search forms to return a formatted resultUse an HTML form and an embedded formatted search on the same topic. You can link them together with an%URLPARAM{"..."}% variable. Example:
Write this:
<form action="%SCRIPTURLPATH%/view%SCRIPTSUFFIX%/%WEB%/%TOPIC%"> Find Topics: <input type="text" name="q" size="32" value="%URLPARAM{"q"}%" /> <input type="submit" value="Search" /> </form> Result: %SEARCH{ search="%URLPARAM{"q"}%" format=" * $web.$topic: %BR% $summary" nosearch="on" }%To get this: Result: Number of topics: 0 -- TWiki:Main.PeterThoeny - 16 Mar 2004 |
| ||||||||||||||||||||||
Line: 24 to 24 | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Variables that can be used in the format string:
| ||||||||||||||||||||||
Changed: | ||||||||||||||||||||||
< < |
| |||||||||||||||||||||
> > |
| |||||||||||||||||||||
| ||||||||||||||||||||||
Line: 125 to 125 | ||||||||||||||||||||||
| ||||||||||||||||||||||
Added: | ||||||||||||||||||||||
> > |
Most recently changed pages | |||||||||||||||||||||
Changed: | ||||||||||||||||||||||
< < |
-- PeterThoeny - 16 May 2002 | |||||||||||||||||||||
> > |
Write this:
%SEARCH{ "\.*" scope="topic" regex="on" nosearch="on" nototal="on" order="modified" reverse="on" format="| [[$topic]] | $wikiusername | $date |" limit="7" }%
To get this:
|
| ||||||||
Line: 29 to 29 | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
Changed: | ||||||||
< < |
| |||||||
> > |
| |||||||
| ||||||||
Line: 42 to 42 | ||||||||
| ||||||||
Changed: | ||||||||
< < |
| |||||||
> > |
| |||||||
|
| ||||||||
Line: 34 to 34 | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
Added: | ||||||||
> > |
| |||||||
| ||||||||
Deleted: | ||||||||
< < |
| |||||||
|
| ||||||||
Line: 14 to 14 | ||||||||
---|---|---|---|---|---|---|---|---|
1. header="..." parameter
| ||||||||
Changed: | ||||||||
< < |
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. Example: header="| *Topic:* | *Summary:* |"
| |||||||
> > |
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. Example: header="| *Topic:* | *Summary:* |"
| |||||||
2. format="..." parameter
|
| ||||||||
Line: 50 to 50 | ||||||||
---|---|---|---|---|---|---|---|---|
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.
| ||||||||
Deleted: | ||||||||
< < |
Nested SearchSearch 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 likescope="text" regex="on" nosearch="on" nototal="on" are omitted for simplicity.
| |||||||
Examples | ||||||||
Line: 76 to 57 | ||||||||
Bullet list showing topic name and summary | ||||||||
Changed: | ||||||||
< < |
Write this: | |||||||
> > |
Write this: | |||||||
%SEARCH{ "FAQ" scope="topic" nosearch="on" nototal="on" header=" * *Topic: Summary:*" format=" * [[$topic]]: $summary" }%
| ||||||||
Changed: | ||||||||
< < |
To get this: | |||||||
> > |
To get this: | |||||||
| ||||||||
Line: 84 to 65 | ||||||||
| ||||||||
Added: | ||||||||
> > |
||||||||
Table showing form field values of topics with a form | ||||||||
Changed: | ||||||||
< < |
Write this in the Know web: | |||||||
> > |
Write this in the Know web: | |||||||
| *Topic:* | *OperatingSystem:* | *OsVersion:* | %SEARCH{ "[T]opicClassification.*?value=\"[P]ublicFAQ\"" scope="text" regex="on" nosearch="on" nototal="on" format="| [[$topic]] | $formfield(OperatingSystem) | $formfield(OsVersion) |" }%
| ||||||||
Changed: | ||||||||
< < |
To get this: | |||||||
> > |
To get this: | |||||||
| ||||||||
Line: 106 to 88 | ||||||||
| ||||||||
Added: | ||||||||
> > |
||||||||
Extract some text from a topic using regular expression | ||||||||
Changed: | ||||||||
< < |
Write this: | |||||||
> > |
Write 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...]]" }%
| ||||||||
Changed: | ||||||||
< < |
To get this: | |||||||
> > |
To get this: | |||||||
TWiki FAQs:
| ||||||||
Added: | ||||||||
> > |
Nested SearchSearch 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).
%SEARCH{ "culture" format=" * $topic is referenced by:$n * $percntSEARCH{ \"$topic\" format=\" $dollartopic\" nosearch=\"on\" nototal=\"on\" }$nop%" nosearch="on" nototal="on" }%
To get this:
| |||||||
-- PeterThoeny - 16 May 2002 |
| |||||||||||||||||||||
Line: 6 to 6 | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Inline search feature allows flexible formatting of search result | |||||||||||||||||||||
Deleted: | |||||||||||||||||||||
< < |
Overview | ||||||||||||||||||||
The %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 %SEARCH{ "food" format="| $topic | $summary |" }% ).
Syntax | |||||||||||||||||||||
Changed: | |||||||||||||||||||||
< < |
Two paramters can be used to specify a customized search result: | ||||||||||||||||||||
> > |
Two parameters can be used to specify a customized search result: | ||||||||||||||||||||
1. header="..." parameter
| |||||||||||||||||||||
Changed: | |||||||||||||||||||||
< < |
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="| *Topic:* | *Summary:* |"
| ||||||||||||||||||||
> > |
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. Example: header="| *Topic:* | *Summary:* |"
| ||||||||||||||||||||
2. format="..." parameter
| |||||||||||||||||||||
Changed: | |||||||||||||||||||||
< < |
Use the format paramter to specify the format of one search hit. I.e. format="| $topic | $summary |"
| ||||||||||||||||||||
> > |
Use the format parameter to specify the format of one search hit.
Example: format="| $topic | $summary |"
| ||||||||||||||||||||
Variables that can be used in the format string:
| |||||||||||||||||||||
Deleted: | |||||||||||||||||||||
< < |
| ||||||||||||||||||||
| |||||||||||||||||||||
Added: | |||||||||||||||||||||
> > |
| ||||||||||||||||||||
| |||||||||||||||||||||
Changed: | |||||||||||||||||||||
< < |
| ||||||||||||||||||||
> > |
| ||||||||||||||||||||
| |||||||||||||||||||||
Changed: | |||||||||||||||||||||
< < |
| ||||||||||||||||||||
> > |
$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.
Nested SearchSearch 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 likescope="text" regex="on" nosearch="on" nototal="on" are omitted for simplicity.
| ||||||||||||||||||||
Deleted: | |||||||||||||||||||||
< < |
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.
| ||||||||||||||||||||
Examples | |||||||||||||||||||||
Added: | |||||||||||||||||||||
> > |
|||||||||||||||||||||
Bullet list showing topic name and summaryWrite this: | |||||||||||||||||||||
Line: 85 to 116 | |||||||||||||||||||||
TWiki FAQs:
| |||||||||||||||||||||
Changed: | |||||||||||||||||||||
< < |
-- PeterThoeny - 28 Nov 2001 | ||||||||||||||||||||
> > |
-- PeterThoeny - 16 May 2002 |
| ||||||||
Line: 28 to 28 | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
Changed: | ||||||||
< < |
| |||||||
> > |
| |||||||
|
| ||||||||
Line: 28 to 28 | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
Added: | ||||||||
> > |
| |||||||
|
| ||||||||
Line: 8 to 8 | ||||||||
---|---|---|---|---|---|---|---|---|
Overview | ||||||||
Changed: | ||||||||
< < |
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. %SEARCH{ "food" format="| $topic | $summary |" }% ).
| |||||||
> > |
The %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 %SEARCH{ "food" format="| $topic | $summary |" }% ).
| |||||||
Syntax |
| ||||||||
Deleted: | ||||||||
< < |
Formatted Search Using %SEARCH{... format="..."}% Variable
| |||||||
TOC: No TOC in "TWiki.FormattedSearch" | ||||||||
Added: | ||||||||
> > |
TWiki Formatted Search ResultsInline search feature allows flexible formatting of search result | |||||||
Changed: | ||||||||
< < |
Preface | |||||||
> > |
Overview | |||||||
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. %SEARCH{ "food" format="| $topic | $summary |" }% ).
|
%SEARCH{... format="..."}% Variable
| ||||||||
Line: 14 to 14 | ||||||||
---|---|---|---|---|---|---|---|---|
1. header="..." parameter
| ||||||||
Changed: | ||||||||
< < |
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="| *Topic:* | *Summary:* |"
| |||||||
> > |
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="| *Topic:* | *Summary:* |"
| |||||||
2. format="..." parameter
| ||||||||
Changed: | ||||||||
< < |
Use the format paramter to specify the format of one search hit. I.e. format="| $topic | $summary |"
| |||||||
> > |
Use the format paramter to specify the format of one search hit. I.e. format="| $topic | $summary |"
| |||||||
Variables that can be used in the format string:
| ||||||||
Added: | ||||||||
> > |
| |||||||
| ||||||||
Changed: | ||||||||
< < |
| |||||||
> > |
| |||||||
| ||||||||
Added: | ||||||||
> > |
| |||||||
| ||||||||
Changed: | ||||||||
< < |
| |||||||
> > |
| |||||||
$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.
| ||||||||
Line: 52 to 55 | ||||||||
Write this in the Know web:
| *Topic:* | *OperatingSystem:* | *OsVersion:* | | ||||||||
Changed: | ||||||||
< < |
%SEARCH{ "[T]opicClassification.*?value=\"[P]ublicFAQ\"" scope="text" regex="on" nosearch="on" nototal="on" format="| [[$topic]] | $formfield(OperatingSystem?) | $formfield(OsVersion?) |" }%
| |||||||
> > |
%SEARCH{ "[T]opicClassification.*?value=\"[P]ublicFAQ\"" scope="text" regex="on" nosearch="on" nototal="on" format="| [[$topic]] | $formfield(OperatingSystem) | $formfield(OsVersion) |" }%
| |||||||
To get this: | ||||||||
Line: 79 to 82 | ||||||||
TWiki FAQs:
| ||||||||
Changed: | ||||||||
< < |
-- PeterThoeny - 24 Oct 2001 | |||||||
> > |
-- PeterThoeny - 28 Nov 2001 |
Line: 1 to 1 | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Added: | |||||||||||||||||||||||||||||||||
> > |
%SEARCH{... format="..."}% Variable
PrefaceBy default, the format for displaying a search result is fixed, e.g. a table with rows of topic name and topic summary. Use theformat="..." 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. %SEARCH{ "food" format="| $topic | $summary |" }% ).
SyntaxTwo paramters can be used to specify a customized search result: 1.header="..." parameter
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="| *Topic:* | *Summary:* |"
2. format="..." parameter
Use the format paramter to specify the format of one search hit. I.e. format="| $topic | $summary |"
Variables that can be used in the format string:
$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.
ExamplesBullet list showing topic name and summaryWrite this:%SEARCH{ "FAQ" scope="topic" nosearch="on" nototal="on" header=" * *Topic: Summary:*" format=" * [[$topic]]: $summary" }%
To get this:
Table showing form field values of topics with a formWrite this in the Know web:| *Topic:* | *OperatingSystem:* | *OsVersion:* | %SEARCH{ "[T]opicClassification.*?value=\"[P]ublicFAQ\"" scope="text" regex="on" nosearch="on" nototal="on" format="| [[$topic]] | $formfield(OperatingSystem?) | $formfield(OsVersion?) |" }%
To get this:
Extract some text from a topic using regular expressionWrite 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...]]" }%
To get this:
TWiki FAQs:
|