Welcome, Registration, and other StartingPoints; TWiki history & Wiki style; All the docs...
View   r3  >  r2  ...
SearchPatternCookbook 3 - 22 Sep 2005 - Main.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


Revision 3r3 - 22 Sep 2005 - 16:24:01 - TWikiContributor
Revision 2r2 - 22 Sep 2005 - 16:24:01 - TWikiContributor
This site is powered by the TWiki collaboration platform.
All material on this collaboration platform is the property of the contributing authors.
All material marked as authored by Eben Moglen is available under the license terms CC-BY-SA version 4.
Syndicate this site RSSATOM