Документ взят из кэша поисковой машины. Адрес оригинального документа : http://dualopt1.cmm.msu.ru/bin/rdiff/TWiki/FormattedSearch?rev1=18;rev2=17;skin=kubrick.nat%2Cnat%2C%20pattern;sortcol=0;table=2;up=0
Дата изменения: Unknown
Дата индексирования: Sun Mar 2 17:51:07 2014
Кодировка:
%TOPICTITLE% (17 vs. 18) - TWiki
Welcome, Registration, and other StartingPoints; TWiki history & Wiki style; All the docs...
View   r18  >  r17  ...
FormattedSearch 18 - 2007-01-14 - Main.TWikiContributor
Line: 1 to 1
 
META TOPICPARENT name="TWikiVariables"
Line: 12 to 12
  Two parameters can be used to specify a customized search result:
Changed:
<
<
1. header="..." parameter
>
>

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.
Example: header="| *Topic:* | *Summary:* |"
Changed:
<
<
2. format="..." parameter
>
>
Variables that can be used in the header string:

Name:
<-- -->
Sorted ascending
Expands To:
$dollar Dollar sign ($)
$n or $n() New line. Use $n() if followed by alphanumeric character, e.g. write Foo$n()Bar instead of Foo$nBar
$nop or $nop() Is a "no operation". This variable gets removed; useful for nested search
$percnt Percent sign (%)
$quot Double quote ("). Alternatively write \" to escape it
$web Name of the web

2. format="..." parameter

  Use the format parameter to specify the format of one search hit.
Example: format="| $topic | $summary |"
Line: 65 to 75
 

Examples

Added:
>
>
Here are some samples of formatted searches. The SearchPatternCookbook has other examples, such as creating a picklist of usernames, searching for topic children and more.
 

Bullet list showing topic name and summary

Line: 83 to 94
 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:* |

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" type="regex" nosearch="on" nototal="on" format="| [[$topic]] | $formfield(OperatingSystem) | $formfield(OsVersion) |" }%
  To get this:
Line: 105 to 116
  Write this:
Changed:
<
<
%SEARCH{ "__Back to\:__ TWikiFAQ" scope="text" regex="on" nosearch="on" nototal="on" header="TWiki FAQs:" format="   * $pattern(.*?FAQ\:[\n\r]*([^\n\r]+).*) [[$topic][Answer...]]" }%
>
>
%SEARCH{ "__Back to\:__ TWikiFAQ" scope="text" type="regex" nosearch="on" nototal="on" header="TWiki FAQs:" format="   * $pattern(.*?FAQ\:[\n\r]*([^\n\r]+).*) [[$topic][Answer...]]" }%
  To get this:
Changed:
<
<
TWiki FAQs:
  • How can I create a simple TWiki Form based application? Answer...
  • How do I delete or rename a topic? Answer...
  • How do I delete or rename a file attachment? Answer...
  • Why does the topic revision not increase when I edit a topic? Answer...
  • TWiki has a GPL (GNU General Public License). What is GPL? Answer...
  • I've problems with the WebSearch. There is no Search Result on any inquiry. By clicking the Index topic it's the same problem. Answer...
  • What happens if two of us try to edit the same topic simultaneously? Answer...
  • I would like to install TWiki on my server. Can I get the source? Answer...
  • What does the "T" in TWiki stand for? Answer...
  • So what is this WikiWiki thing exactly? Answer...
  • Everybody can edit any page, this is scary. Doesn't that lead to chaos? Answer...
>
>
TWiki FAQs:
  • How can I create a simple TWiki Form based application? Answer...
  • How do I delete or rename a topic? Answer...
  • How do I delete or rename a file attachment? Answer...
  • Why does the topic revision not increase when I edit a topic? Answer...
  • TWiki has a GPL (GNU General Public License). What is GPL? Answer...
  • I've problems with the WebSearch. There is no Search Result on any inquiry. By clicking the Index topic it's the same problem. Answer...
  • What happens if two of us try to edit the same topic simultaneously? Answer...
  • I would like to install TWiki on my server. Can I get the source? Answer...
  • What does the "T" in TWiki stand for? Answer...
  • So what is this WikiWiki thing exactly? Answer...
  • Everybody can edit any page, this is scary. Doesn't that lead to chaos? Answer...
 

Nested Search

Line: 142 to 153
  Write this:
Changed:
<
<
%SEARCH{ "\.*" scope="topic" regex="on" nosearch="on" nototal="on" order="modified" reverse="on"  format="| [[$topic]] | $wikiusername  | $date |" limit="7" }%
>
>
%SEARCH{ "\.*" scope="topic" type="regex" nosearch="on" nototal="on" order="modified" reverse="on"  format="| [[$topic]] | $wikiusername  | $date |" limit="7" }%
  To get this:
Changed:
<
<
SiteEditorsGroup TWikiAdminUser 2009-10-12 - 20:34
TWikiWebButtons TWikiAdminUser 2009-10-12 - 18:03
FlexWebListNavi TWikiAdminUser 2009-10-12 - 18:00
TWikiWebSideBar TWikiAdminUser 2009-10-12 - 17:58
WebLeftBar TWikiAdminUser 2009-10-12 - 17:56
TWikiPreferences TWikiAdminUser 2009-10-12 - 17:34
WebLeftBarWebsList TWikiAdminUser 2009-10-12 - 17:29
>
>
SiteEditorsGroup TWikiAdminUser 2009-10-12 - 20:34
TWikiWebButtons TWikiAdminUser 2009-10-12 - 18:03
FlexWebListNavi TWikiAdminUser 2009-10-12 - 18:00
TWikiWebSideBar TWikiAdminUser 2009-10-12 - 17:58
WebLeftBar TWikiAdminUser 2009-10-12 - 17:56
TWikiPreferences TWikiAdminUser 2009-10-12 - 17:34
WebLeftBarWebsList TWikiAdminUser 2009-10-12 - 17:29
 

Search with conditional output

Line: 161 to 172
 Write this:

%CALC{$SET(weekold, $TIMEADD($TIME(), -7, day))}%

Changed:
<
<
%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" }%
>
>
%SEARCH{ "." scope="topic" type="regex" nosearch="on" nototal="on" order="modified" reverse="on" format="$percntCALC{$IF($TIME($date) < $GET(weekold), <nop>, | [[$topic]] | $wikiusername | $date | $rev |)}$percnt" limit="100" }%
 
  • The first line sets the weekold variable to the serialized date of exactly one week ago
  • The SEARCH has a deferred CALC. The $percnt makes sure that the CALC gets executed once for each search hit
Line: 172 to 183
 To get this:
Changed:
<
<
>
>
 

Embedding search forms to return a formatted result

Line: 198 to 209
 Result:
Changed:
<
<
Related Topics: UserDocumentationCategory
>
>
Related Topics: UserDocumentationCategory, SearchHelp, TWikiVariables#VarSEARCH, SearchPatternCookbook, RegularExpression
 
Added:
>
>
-- Contributors: TWiki:Main.PeterThoeny, TWiki:Main.CrawfordCurrie

Revision 18r18 - 2007-01-14 - 00:44:52 - TWikiContributor
Revision 17r17 - 2005-03-27 - 13:14:15 - TWikiContributor
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback
Note: Please contribute updates to this topic on TWiki.org at TWiki:TWiki.FormattedSearch
Syndicate this site RSSATOM