none
authorPeterThoeny <PeterThoeny>
Thu, 25 Oct 2001 02:13:01 +0000 (02:13 +0000)
committerPeterThoeny <PeterThoeny>
Thu, 25 Oct 2001 02:13:01 +0000 (02:13 +0000)
TWiki/FormattedSearch.mdwn [new file with mode: 0644]
TWiki/TWikiVariables.mdwn

diff --git a/TWiki/FormattedSearch.mdwn b/TWiki/FormattedSearch.mdwn
new file mode 100644 (file)
index 0000000..6b5e479
--- /dev/null
@@ -0,0 +1,143 @@
+**Formatted Search Using <code>**%SEARCH\{... format="..."\}%**</code> Variable**
+
+<div>
+  <ul>
+    <li>
+      <ul>
+        <li><a href="#Preface"> Preface</a></li>
+        <li><a href="#Syntax"> Syntax</a></li>
+        <li><a href="#Examples"> Examples</a><ul>
+            <li><a href="#Bullet list showing topic name a"> Bullet list showing topic name and summary</a></li>
+          </ul>
+        </li>
+      </ul>
+    </li>
+    <li><a href="#TWiki Installation Error">TWiki Installation Error</a><ul>
+        <li>
+          <ul>
+            <li><a href="#Table showing form field values"> Table showing form field values of topics with a form</a></li>
+            <li><a href="#Extract some text from a topic u"> Extract some text from a topic using regular expression</a></li>
+          </ul>
+        </li>
+      </ul>
+    </li>
+    <li><a href="#TWiki Installation Error">TWiki Installation Error</a></li>
+  </ul>
+</div>
+
+## <a name="Preface"></a> Preface
+
+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 |" }%`).
+
+## <a name="Syntax"></a> Syntax
+
+Two 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:
+
+<table border="1" cellpadding="0" cellspacing="0">
+  <tr>
+    <th bgcolor="#99CCCC"><strong> Name: </strong></th>
+    <th bgcolor="#99CCCC"><strong> Expands To: </strong></th>
+  </tr>
+  <tr>
+    <td><code>$web</code></td>
+    <td> Name of the web </td>
+  </tr>
+  <tr>
+    <td><code>$topic</code></td>
+    <td> Topic name </td>
+  </tr>
+  <tr>
+    <td><code>$locked</code></td>
+    <td> LOCKED flag (if any) </td>
+  </tr>
+  <tr>
+    <td><code>$date</code></td>
+    <td> Time stamp of last topic update </td>
+  </tr>
+  <tr>
+    <td><code>$rev</code></td>
+    <td> Number of last topic revision, i.e. <code>1.4</code></td>
+  </tr>
+  <tr>
+    <td><code>$wikiusername</code></td>
+    <td> Wiki user name of last topic update, i.e. <code>Main.JohnSmith</code></td>
+  </tr>
+  <tr>
+    <td><code>$summary</code></td>
+    <td> Topic summary </td>
+  </tr>
+  <tr>
+    <td><code>$formfield(name)</code></td>
+    <td> The field value of a form field, i.e. <code>$formfield([[Main/TopicClassification]])</code> would get expanded to <code>PublicFAQ</code>. This applies only to topics that have a [[Main/TWikiForms]]</td>
+  </tr>
+  <tr>
+    <td><code>$pattern(reg-exp)</code></td>
+    <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>
+  </tr>
+</table>
+
+**_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.
+
+## <a name="Examples"></a> Examples
+
+### <a name="Bullet list showing topic name a"></a> Bullet list showing topic name and summary
+
+Write this:
+
+`%SEARCH{ "FAQ" scope="topic" nosearch="on" nototal="on" header="   * *Topic: Summary:*" format="   * [[$topic]]: $summary" }%`
+
+To get this:
+
+# <a name="TWiki Installation Error"></a> TWiki Installation Error
+
+Incorrect format of searchformat template (missing sections? There should be 4 %SPLIT% tags)
+
+### <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
+
+Write this in the Know web:
+
+`| *Topic:* | *OperatingSystem:* | *OsVersion:* |`<br /><code>%SEARCH\{ "[T]opicClassification.\*?value=\\"[P]ublicFAQ\\"" scope="text" regex="on" nosearch="on" nototal="on" format="| \[[$topic]] | $formfield([[OperatingSystem]]) | $formfield([[OsVersion]]) |" \}%</code>
+
+To get this:
+
+<table border="1" cellpadding="1" cellspacing="0">
+  <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="http://www.dementia.org/twiki//view/Know/IncorrectDllVersionW32PTH10DLL">IncorrectDllVersionW32PTH10DLL</a></td>
+    <td><a href="http://www.dementia.org/twiki//view/Know/OsWin">OsWin</a></td>
+    <td> 95/98 </td>
+  </tr>
+  <tr>
+    <td><a href="http://www.dementia.org/twiki//view/Know/WinDoze95Crash">WinDoze95Crash</a></td>
+    <td><a href="http://www.dementia.org/twiki//view/Know/OsWin">OsWin</a></td>
+    <td> 95 </td>
+  </tr>
+</table>
+
+### <a name="Extract some text from a topic u"></a> Extract some text from a topic using regular expression
+
+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...]]" }%`
+
+To get this:
+
+# <a name="TWiki Installation Error"></a> TWiki Installation Error
+
+Incorrect format of searchformat template (missing sections? There should be 4 %SPLIT% tags)
+
+-- [[PeterThoeny]] - 24 Oct 2001 <br />
index a41659f..b0a70c6 100644 (file)
@@ -217,7 +217,7 @@ With a couple of notable exceptions, predefined variables return set values that
       </tr>
       <tr>
         <td><code>%GMTIME%</code></td>
-        <td> GM time, is <b>29 Jun 2010 - 15:30</b></td>
+        <td> GM time, is <b>29 Jun 2010 - 15:31</b></td>
       </tr>
       <tr>
         <td><code>%GMTIME{"format"}%</code></td>
@@ -267,15 +267,15 @@ With a couple of notable exceptions, predefined variables return set values that
               <td> 2 digit year </td>
               <td> 99 </td>
             </tr>
-          </table> Variables can be shortened to 3 characters. Example: <br /><code>%GMTIME{"$day $month, $year - $hour:$min:$sec"}%</code> is <br /><b>29 Jun, 2010 - 15:30:48</b></td>
+          </table> Variables can be shortened to 3 characters. Example: <br /><code>%GMTIME{"$day $month, $year - $hour:$min:$sec"}%</code> is <br /><b>29 Jun, 2010 - 15:31:15</b></td>
       </tr>
       <tr>
         <td><code>%SERVERTIME%</code></td>
-        <td> Server time, is <b>29 Jun 2010 - 11:30</b></td>
+        <td> Server time, is <b>29 Jun 2010 - 11:31</b></td>
       </tr>
       <tr>
         <td><code>%SERVERTIME{"format"}%</code></td>
-        <td> Formatted server time. <br /> Example: <code>%SERVERTIME{"$hou:$min"}%</code> is <b>11:30</b></td>
+        <td> Formatted server time. <br /> Example: <code>%SERVERTIME{"$hou:$min"}%</code> is <b>11:31</b></td>
       </tr>
       <tr>
         <td><code>%HTTP_HOST%</code></td>
@@ -403,13 +403,23 @@ With a couple of notable exceptions, predefined variables return set values that
             </tr>
             <tr>
               <td><code>nosummary="on"</code></td>
-              <td> Show topic title only </td>
+              <td> Show topic title only. [3] </td>
               <td> Show topic summary </td>
             </tr>
             <tr>
               <td><code>bookview="on"</code></td>
-              <td>[[Main/BookView]] search, e.g. show complete topic text </td>
-              <td> Show topic summary </td>
+              <td>[[Main/BookView]] search, e.g. show complete topic text. [3] </td>
+              <td> Show topic summary. </td>
+            </tr>
+            <tr>
+              <td><code>format="..."</code></td>
+              <td> Define a [[Main/FormattedSearch]], i.e. <br /><code>"   * [[$topic]]: $summary"</code>. [3] </td>
+              <td> Show regular search result with topic summary </td>
+            </tr>
+            <tr>
+              <td><code>header="..."</code></td>
+              <td> Specify header of [[Main/FormattedSearch]], i.e. <br /><code>"   * *Topic: Summary:*"</code>. </td>
+              <td> Show regular header </td>
             </tr>
             <tr>
               <td><code>nosearch="on"</code></td>
@@ -470,6 +480,8 @@ With a couple of notable exceptions, predefined variables return set values that
 > : The search form uses identical names for input fields.
 >
 > [2] **_Note_**: A web can be excluded from a `web="all"` search if you define a `NOSEARCHALL=on` variable in its [[WebPreferences]].
+>
+> [3] **_Note_**: Regular search, no summary, [[BookView]] and [[FormattedSearch]] are exclusive.
 
 ## <a name="Preferences Variables"></a> Preferences Variables