
| 
 On this page:  
 TWiki Formatted Search ResultsInline 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 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 (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. | ||||||||||||||||
| Added: | |||||||||||||||||
| > > | Example: format="| $topic | $summary |" | ||||||||||||||||
| Variables that can be used in the format string: 
 | |||||||||||||||||
| Deleted: | |||||||||||||||||
| < < | 
 | ||||||||||||||||
| 
 | |||||||||||||||||
| Added: | |||||||||||||||||
| > > | 
 | ||||||||||||||||
| 
 | |||||||||||||||||
| Changed: | |||||||||||||||||
| < < | 
 | ||||||||||||||||
| > > | 
 | ||||||||||||||||
| 
 | |||||||||||||||||
| Changed: | |||||||||||||||||
| < < | 
 | ||||||||||||||||
| > > | 
 | ||||||||||||||||
| Added: | |||||||||||||||||
| > > | 
 | ||||||||||||||||
| Changed: | |||||||||||||||||
| < < | 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. | ||||||||||||||||
| > > | 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. | ||||||||||||||||
| 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. 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 | |||||||||||||||||
| Added: | |||||||||||||||||
| > > | |||||||||||||||||
| Bullet 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:
 | |||||||||||||||||
| Changed: | |||||||||||||||||
| < < | -- PeterThoeny - 28 Nov 2001 | ||||||||||||||||
| > > | -- PeterThoeny - 16 May 2002 | ||||||||||||||||
 
  Copyright © 1999-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Copyright © 1999-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.