Difference: SearchPatternCookbook (2 vs. 3)

Revision 32005-09-22 - TWikiContributor

Line: 1 to 1
 

Search Pattern Cookbook

The Search function in TWiki is very powerful. Especially searches using a RegularExpression play an important part of tapping TWiki's full potential. Unfortunately RegularExpressions can be incredibly obscure to the uninitiated.

Line: 85 to 85
 This will create similar functionality as TWiki:Plugins.TopicClassificationAddOn
Changed:
<
<

Pattern 3a: listbox with all user names

>
>

Pattern 3: Creating lists of TWiki usernames

 

Problem

How to populate a list box with all usernames of registered TWiki users

Changed:
<
<

Solution

>
>

Solution 1: Appropriate for Sep 2004 TWiki (Cairo)

 
<form name="testing" action="%SCRIPTURLPATH{"view"}%/%MAINWEB%" method="get">
Line: 115 to 115
  This searches all topics in the Main web that contain "Name", "Email" and "Country" bullets. Alternatively, do a FormattedSearch with multiple="on" on the Main.TWikiUsers topic.
Changed:
<
<

Pattern 3b: listbox with all user names - select multiple names

Problem

Suppose you want to send mail from a form on topic page to a selected list of multiple TWikiUsers

Solution

The example of Pattern 3a produces the list box. Add a MULTIPLE to the select statement, i.e.:
>
>

Solution 2: As Solution 1, but with possibility for multi-selecting usernames

The example of Solution 1 produces the list box. Add a MULTIPLE to the select statement, i.e.:
 
<select name="topic" size="2" MULTIPLE>
Changed:
<
<
Please note that the Search pattern is unchanged compared to Pattern 3a. The change is in the HTML form element.
>
>
Please note that the Search pattern is unchanged compared to Solution 1. The change is in the HTML form element.
 
Changed:
<
<

Test case

The Search pattern 3a with the abovementioned modification is, in effect:
>
>
The abovementioned modification is, in effect:
 
Line: 139 to 132
 
Added:
>
>

Solution 3: Appropriate for TWiki 4 (Dakar)

When the User information is stored in a UserForm (as is default in Dakar) then this list can be generated as follows:

<form name="testing" action="%SCRIPTURLPATH{"view"}%/%MAINWEB%" method="get">
<select name="topic">
<option>Select user...</option>
%SEARCH{"%META:FORM.*[U]serForm" web="%MAINWEB%" regex="on" casesensitive="on" nosearch="on" format="<option>$topic</option>" sort="topic" excludetopic="Test*, TWiki*"}%
</select>
<input type="submit" value="Go" />
</form>

In the above example:

  • META:FORM.*[U]serForm will search for all topics with a UserForm attached - change this if you have a different form where userdata is stored. Please note that this search does not actually extract anything from the form - it just uses it to identify the appropriate pages
  • excludetopic="Test*, TWiki*" allows to skip all topics starting with Test and TWiki, such as TestUser or TWikiAdmin. Use this if you have any special users who you do not want appearing in this list
 

Pattern 4: Extract the parent of a given topic

 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 1999-2019 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.SearchPatternCookbook.