3 <li><a href="#TWiki Formatted Search Results"> TWiki Formatted Search Results</a><ul>
4 <li><a href="#Overview"> Overview</a></li>
5 <li><a href="#Syntax"> Syntax</a></li>
6 <li><a href="#Examples"> Examples</a><ul>
7 <li><a href="#Bullet list showing topic name a"> Bullet list showing topic name and summary</a></li>
12 <li><a href="#TWiki Installation Error">TWiki Installation Error</a><ul>
15 <li><a href="#Table showing form field values"> Table showing form field values of topics with a form</a></li>
16 <li><a href="#Extract some text from a topic u"> Extract some text from a topic using regular expression</a></li>
21 <li><a href="#TWiki Installation Error">TWiki Installation Error</a></li>
25 # <a name="TWiki Formatted Search Results"></a> TWiki Formatted Search Results
27 _Inline search feature allows flexible formatting of search result_
29 ## <a name="Overview"></a> Overview
31 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 |" }%`).
33 ## <a name="Syntax"></a> Syntax
35 Two paramters can be used to specify a customized search result:
37 1. `header="..."` parameter
39 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="| *Topic:* | *Summary:* |"`
41 2. `format="..."` parameter
43 Use the format paramter to specify the format of one search hit. I.e. <br />`format="| $topic | $summary |"`
45 Variables that can be used in the format string:
47 <table border="1" cellpadding="0" cellspacing="0">
49 <th bgcolor="#99CCCC"><strong> Name: </strong></th>
50 <th bgcolor="#99CCCC"><strong> Expands To: </strong></th>
53 <td><code>$n</code></td>
57 <td><code>$web</code></td>
58 <td> Name of the web </td>
61 <td><code>$topic</code></td>
65 <td><code>$locked</code></td>
66 <td> LOCKED flag (if any) </td>
69 <td><code>$date</code></td>
70 <td> Time stamp of last topic update, i.e. <code>29 Jun 2010 - 15:32</code></td>
73 <td><code>$isodate</code></td>
74 <td> Time stamp of last topic update, i.e. <code>2010-06-29T15:32Z</code></td>
77 <td><code>$rev</code></td>
78 <td> Number of last topic revision, i.e. <code>1.4</code></td>
81 <td><code>$wikiusername</code></td>
82 <td> Wiki user name of last topic update, i.e. <code>Main.JohnSmith</code></td>
85 <td><code>$username</code></td>
86 <td> User name of last topic update, i.e. <code>JohnSmith</code></td>
89 <td><code>$summary</code></td>
90 <td> Topic summary </td>
93 <td><code>$formfield(name)</code></td>
94 <td> The field value of a form field, i.e. <code>$formfield(TopicClassification)</code> would get expanded to <code>PublicFAQ</code>. This applies only to topics that have a [[Main/TWikiForms]]</td>
97 <td><code>$pattern(reg-exp)</code></td>
98 <td> A regular expression pattern to extract some text from a topic, i.e. <code>$pattern(.*?\*.*?Email\:\s*([^\n\r]+).*)</code> extracts the email address from a bullet of format <code>* Email: ...</code>. </td>
102 **_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.
104 ## <a name="Examples"></a> Examples
106 ### <a name="Bullet list showing topic name a"></a> Bullet list showing topic name and summary
110 `%SEARCH{ "FAQ" scope="topic" nosearch="on" nototal="on" header=" * *Topic: Summary:*" format=" * [[$topic]]: $summary" }%`
114 # <a name="TWiki Installation Error"></a> TWiki Installation Error
116 Incorrect format of searchformat template (missing sections? There should be 4 %SPLIT% tags)
118 ### <a name="Table showing form field values"></a><a name="Table showing form field values "></a> Table showing form field values of topics with a form
120 Write this in the Know web:
122 `| *Topic:* | *OperatingSystem:* | *OsVersion:* |`<br />`%SEARCH{ "[T]opicClassification.*?value=\"[P]ublicFAQ\"" scope="text" regex="on" nosearch="on" nototal="on" format="| [[$topic]] | $formfield(OperatingSystem) | $formfield(OsVersion) |" }%`
126 <table border="1" cellpadding="1" cellspacing="0">
128 <th bgcolor="#99CCCC"><strong>Topic:</strong></th>
129 <th bgcolor="#99CCCC"><strong>OperatingSystem:</strong></th>
130 <th bgcolor="#99CCCC"><strong>OsVersion:</strong></th>
133 <td><a href="http://www.dementia.org/twiki//view/Know/IncorrectDllVersionW32PTH10DLL">IncorrectDllVersionW32PTH10DLL</a></td>
134 <td><a href="http://www.dementia.org/twiki//view/Know/OsWin">OsWin</a></td>
138 <td><a href="http://www.dementia.org/twiki//view/Know/WinDoze95Crash">WinDoze95Crash</a></td>
139 <td><a href="http://www.dementia.org/twiki//view/Know/OsWin">OsWin</a></td>
144 ### <a name="Extract some text from a topic u"></a> Extract some text from a topic using regular expression
148 `%SEARCH{ "__Back to\:__ TWikiFAQ" scope="text" regex="on" nosearch="on" nototal="on" header="TWiki FAQs:" format=" * $pattern(.*?FAQ\:[\n\r]*([^\n\r]+).*) [[$topic][Answer...]]" }%`
152 # <a name="TWiki Installation Error"></a> TWiki Installation Error
154 Incorrect format of searchformat template (missing sections? There should be 4 %SPLIT% tags)
156 -- [[PeterThoeny]] - 28 Nov 2001 <br />