Difference: FormattedSearch (23 vs. 24)

Revision 242012-04-18 - TWikiContributor

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

TWiki Formatted Search

Line: 50 to 50
 
$createusername Login name of topic revision 1, e.g. jsmith
$createwikiname Wiki user name of topic revision 1, e.g. JohnSmith
$createwikiusername Wiki user name of topic revision 1, e.g. Main.JohnSmith
Changed:
<
<
$summary Topic summary, just the plain text, all formatting and line breaks removed; up to 162 characters
>
>
$summary Topic summary, just the plain text, all TWiki variables, formatting and line breaks removed; up to 162 characters
 
$summary(50) Topic summary, up to 50 characters shown
$summary(showvarnames) Topic summary, with %ALLTWIKI{...}% variables shown as ALLTWIKI{...}
Added:
>
>
$summary(expandvar) Topic summary, with %ALLTWIKI{...}% variables expanded
 
$summary(noheader) Topic summary, with leading ---+ headers removed
Note: The tokens can be combined, for example $summary(100, showvarnames, noheader)
$changes Summary of changes between latest rev and previous rev
$changes(n) Summary of changes between latest rev and rev n
Line: 173 to 174
 
  1. If needed, format and output the result
  2. Else supress the search hit
Changed:
<
<
This requires the TWiki:Plugins.SpreadSheetPlugin. The following example shows all topics that are up to exactly one week old.
>
>
This requires the TWiki:Plugins.SpreadSheetPlugin. The following example shows all topics in the Main web that have been updated in the last 7 days.
  Write this:

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

Changed:
<
<
%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" }%
>
>
%SEARCH{ "." scope="topic" type="regex" web="Main" nonoise="on" order="modified" reverse="on" format="$percntCALC{$IF($TIME($date) < $GET(weekold), <nop>, | [[$web.$topic][$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: 189 to 190
 To get this:
Changed:
<
<
>
>
TWikiUsers DaveCostello 2017-12-11 - 17:50 245

The condition can be anything you like. To restrict search based on a date range it is easier to use the date="" parameter as shown in the next example.

Restrict search based on a date range

A search can be restricted based on a date range. The following example is identical to the previous one, showing all topics in the Main web that have been updated in the last 7 days.

Write this:

%SEARCH{ "." scope="topic" type="regex" web="Main" nonoise="on" order="modified" reverse="on" format="| [[$web.$topic][$topic]] | $wikiusername | $date | $rev |" limit="100" date="P1w/$today" }%

To get this:

 

Embedding search forms to return a formatted result

 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding URCS? Send feedback
Note: Please contribute updates to this topic on TWiki.org at TWiki:TWiki.FormattedSearch.