Difference: FormattedSearch (20 vs. 21)

Revision 212009-02-06 - TWikiContributor

Line: 1 to 1
 
META TOPICPARENT name="TWikiVariables"

TWiki Formatted Search

Line: 23 to 23
 
$web Name of the web
$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
$quot or \" Double quote (")
$aquot Apostrophe quote (')
$percnt Percent sign (%)
$dollar Dollar sign ($)
$lt Less than sign (<)
$gt Greater than sign (>)
Changed:
<
<

2. format="..." parameter

>
>

2. footer="..." parameter

Use the footer parameter to specify the footer of a search result. It should correspond to the format of the format parameter. This parameter is optional.
Example: footer="| *Topic* | *Summary* |"

Variables that can be used in the footer string:

Name:
<-- -->
Sorted ascending
Expands To:
$aquot Apostrophe quote (')
$dollar Dollar sign ($)
$gt Greater than sign (>)
$lt Less than sign (<)
$n or $n() New line. Use $n() if followed by alphanumeric character, e.g. write Foo$n()Bar instead of Foo$nBar
$nhits Number of hits if multiple="on". Cumulative across all topics in current web. Identical to $ntopics unless multiple="on"
$nop or $nop() Is a "no operation". This variable gets removed; useful for nested search
$ntopics Number of topics found in current web
$percnt Percent sign (%)
$quot or \" Double quote (")
$web Name of the web

3. format="..." parameter

  Use the format parameter to specify the format of one search hit.
Example: format="| $topic | $summary |"
Line: 63 to 76
 
$formfield(name, 30, ...) Form field value, shortended to 30 characters with "..." indication
$pattern(reg-exp) A regular expression pattern to extract some text from a topic (does not search meta data; use $formfield instead). In case of a multiple="on" search, the pattern is applied to the line found in each search hit.
• Specify a RegularExpression that covers the whole text (topic or line), which typically starts with .*, and must end in .*
• Put text you want to keep in parenthesis, like $pattern(.*?(from here.*?to here).*)
• Example: $pattern(.*?\*.*?Email\:\s*([^\n\r]+).*) extracts the e-mail address from a bullet of format * Email: ...
• This example has non-greedy .*? patterns to scan for the first occurance of the Email bullet; use greedy .* patterns to scan for the last occurance
• Limitation: Do not use .*) inside the pattern, e.g. $pattern(.*foo(.*)bar.*) does not work, but $pattern(.*foo(.*?)bar.*) does
• Note: Make sure that the integrity of a web page is not compromised; for example, if you include an HTML table make sure to include everything including the table end tag
$count(reg-exp) Count of number of times a regular expression pattern appears in the text of a topic (does not search meta data). Follows guidelines for use and limitations outlined above under $pattern(reg-exp). Example: $count(.*?(---[+][+][+][+]) .*) counts the number of <H4> headers in a page.
Added:
>
>
$ntopics Number of topics found in current web. This is the current topic count, not the total number of topics
$nhits Number of hits if multiple="on". Cumulative across all topics in current web. Identical to $ntopics unless multiple="on"
 
$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
$quot or \" Double quote (")
$aquot Apostrophe quote (')
$percnt Percent sign (%)
$dollar Dollar sign ($)
$lt Less than sign (<)
$gt Greater than sign (>)

Examples

Line: 74 to 89
  Write this:
Changed:
<
<
%SEARCH{ "FAQ" scope="topic" nosearch="on" nototal="on" header="   * *Topic: Summary:*" format="   * [[$topic]]: $summary" }%
>
>
%SEARCH{ "FAQ" scope="topic" nosearch="on" nototal="on" header="   * *Topic: Summary:*" format="   * [[$topic]]: $summary"  footer="   * *Topic: Summary*"  }%
  To get this:
Changed:
<
<
  • Topic: Summary:
  • TWikiFAQ: Frequently Asked Questions About TWiki This is a real FAQ, and also a demo of an easily implemented knowledge base solution. To see how it`s done, view the source...
  • TWikiFaqTemplate: FAQ: Answer: Back to: TWikiFAQ Contributors:
  • TextFormattingFAQ: Text Formatting FAQ This topics lists frequently asked questions on text formatting. Text formatting applies to people who edit TWiki pages in raw edit mode. TextFormattingRules...
>
>
  • Topic: Summary:
  • TWikiFAQ: Frequently Asked Questions About TWiki This is a real FAQ, and also a demo of an easily implemented knowledge base solution. To see how it`s done, view the source...
  • TWikiFaqTemplate: FAQ: Answer: Back to: TWikiFAQ Contributors:
  • TextFormattingFAQ: Text Formatting FAQ This topics lists frequently asked questions on text formatting. Text formatting applies to people who edit TWiki pages in raw edit mode. TextFormattingRules...
  • Topic: Summary
 

Table showing form field values of topics with a form

Line: 203 to 218
  Related Topics: UserDocumentationCategory, SearchHelp, TWikiVariables#VarSEARCH, SearchPatternCookbook, RegularExpression
Changed:
<
<
-- Contributors: TWiki:Main.PeterThoeny, TWiki:Main.CrawfordCurrie
>
>
-- Contributors: TWiki:Main.PeterThoeny, TWiki:Main.CrawfordCurrie, TWiki:Main.SopanShewale
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 1999-2024 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.