| *Name* | *Type* | *Tooltip message* | | option1 | option | | | option2 | option | | | option3 | option | |How to extract the 'name' values, i.e. 'option1', 'option2' and 'option3' and put them in a HTML form select input?
<form> <select> %SEARCH{ "^\|[^\|]*\| *option *\|" topic="%TOPIC%" type="regex" multiple="on" nosearch="on" nototal="on" format="<option>$pattern(^\| *(.*?) *\|.*)</option>" }% </select> </form>which is, in effect:
%SEARCH{"[T]opicClassification.*value\=.*Two;[T]opicStatus.*value\=.*%URLPARAM{type}%" type="regex" casesensitive="on" nosearch="on" format=" * $topic - <font face=\"arial,helvetica\" size=\"1\"> _last modified by_ $wikiusername _on_ $date </font> %BR% <font face=\"arial,helvetica\" size=\"1\"> $formfield(TopicStatus) </font>" sort="topic"}%The filtering select dialogue is created as in Pattern 1:
%STARTSIDEBAR% *Filter:* %BR% <form name="selectType" action="%SCRIPTURLPATH{"view"}%/%WEB%/" > <select name="type" size="1" onchange="document.location=this.value;"> %SEARCH{ "^\|[^\|]*\| *option *\|" topic="TopicClassification" web="%WEB%" type="regex" multiple="on" nosearch="on" nototal="on" format="<option value=%INCLUDINGTOPIC%?type=$pattern(^\| *(.*?) *\|.*)>$pattern(^\| *(.*?) *\|.*)</option>" }% <option value=%INCLUDINGTOPIC%>All pages</option> </select> </form> %STOPSIDEBAR%This will create similar functionality as TWiki:Plugins.TopicClassificationAddOn
<form name="testing" action="%SCRIPTURLPATH{"view"}%/%USERSWEB%" method="get"> <select name="topic"> <option>Select user...</option> %SEARCH{ "Name:;Email:;Country:" web="%USERSWEB%" type="regex" nosearch="on" nototal="on" format="<option>$topic</option>" }% </select> <input type="submit" value="Go" /> </form>Which expands to this: (here limited to all Z* users because TWiki.org has so many) This searches all topics in the Main web that contain "Name", "Email" and "Country" bullets. Alternatively, do a FormattedSearch with
multiple="on"
on the Public.TWikiUsers topic.
<select name="topic" size="2" MULTIPLE>Please note that the Search pattern is unchanged compared to Solution 1. The change is in the HTML form element. The abovementioned modification is, in effect:
<form name="testing" action="%SCRIPTURLPATH{"view"}%/%USERSWEB%" method="get"> <select name="topic"> <option>Select user...</option> %SEARCH{"%META:FORM.*[U]serForm" web="%USERSWEB%" type="regex" 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
%META{ "parent" dontrecurse="on" }%
%SEARCH{ "^%BASETOPIC%$" scope="topic" nosearch="on" type="regex" nonoise="on" format=" * $parent" }%However, the
$parent
link fails if the topic has no parent set ($parent
will be empty). You can use some TWiki:Plugins/SpreadSheetPlugin magic to conditionally link to the parent or to WebHome
:
$percntCALCULATE{$IF($EXACT($parent,), <nop>, $NOP( * $parent))}$percntSo the total Search query to find a topic's parent topic is:
%SEARCH{ "^%BASETOPIC%$" scope="topic" type="regex" nonoise="on" format="$percntCALCULATE{$IF($EXACT($parent,), <nop>, $NOP( * $parent))}$percnt" }%
%IF%
, removing the dependency on SpreadSheetPlugin:
%SEARCH{ "^%BASETOPIC%$" web="%BASEWEB%" scope="topic" type="regex" nonoise="on" format="$percntIF{$quot$parent$quot then=$quot * $parent$quot else=$quot<nop>$quot}$percnt" }%
Children: %SEARCH{ "META\:TOPICPARENT.*\"%TOPIC%\"" type="regex" nonoise="on" format="[[$topic]]" separator=", " }%Note: Replace
%TOPIC%
with %BASETOPIC%
if you put this SEARCH into the skin or a sidebar.
<form> <select name="topic"> <option value="%TOPIC%">Select...</option> %SEARCH{ "%HOMETOPIC%" scope="topic" web="all" topic="%HOMETOPIC%" format="<option value=\"$web.$topic\">$web</option>" separator=" " }% </select> <input type="submit" value="Go" /> </form>
Exclude web from a web="all" search
setting in the relevant web's WebPreferences topic.
<select name="type"> <option>Select category...</option> %SEARCH{" *\s*.*?" topic="CategoryList" type="regex" multiple="on" casesensitive="on" nosummary="on" nosearch="on" noheader="on" nototal="on" format="<option>$pattern(.* \*\s*([^\n]*).*)</option>"}% </select>To render the bullet list as a comma-separated list, use the
separator
parameter:
%SEARCH{" *\s*.*?" topic="CategoryList" type="regex" multiple="on" casesensitive="on" nosummary="on" nosearch="on" noheader="on" nototal="on" separator="," format="$pattern(.* \*\s*([^\n]*).*)"}%
Name:
entry.
%SEARCH{" * [N]ame: " topic="%TOPIC%" type="regex" casesensitive="on" nosummary="on" nosearch="on" noheader="on" nototal="on" format="---+!! $pattern(.* \* Name: ([^\n]*).*)"}%
td..td
in the search expression?
%SEARCH{ "[S]tatus.*(td..td|value\=).*[W]aiting" casesensitive="on" type="regex" nosearch="on" nototal="on" format="| [[$topic]]<br /> ($date - $rev - [[%SCRIPTURLPATH{rdiff}%/$web/$topic][Diffs]]) |"}%
%META:FIELD{name="OperatingSystem" title="OperatingSystem" value="OsWin"}%So a search for a form field could look like:
%SEARCH{ "[O]peratingSystem.*value\=.*[O]sWin" type="regex" ... }%
.*
indicate that there can be any number of characters between OperatingSystem
and value
in the (whole) file
<td valign="top" align="right"> OperatingSystem: </td><td> OsWin </td>The following search finds topics in the old and new format:
%SEARCH{ "[O]peratingSystem.*(td..td|value\=).*[O]sWin" type="regex" ... }%The
td..td
matches td<>td
; a simple search on "[O]peratingSystem.*[O]sWin"
could find a hit in the topic text by coincidence.
A simple %SEARCH{ "[O]peratingSystem.*value\=.*[O]sWin" ...}%
search is sufficient if you do not have topics in the old format.
Moved topics: %SEARCH{ "%META\:TOPICMOVED" type="regex" format="$topic, " nosearch="on" noheader="on" nosummary="on" }%
to get this (limited to 10 results):
Moved topics: Number of topics: 0
Related Topics: UserDocumentationCategory, SearchHelp, TWikiVariables#VarSEARCH, FormattedSearch, RegularExpression
-- Contributors: TWiki:Main.AntonAylward, TWiki:Main.ArthurClemens, TWiki:Main.JosMaccabiani, TWiki:Main.PeterThoeny, TWiki:Main.SueLocke
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Daya Bay? Send feedback Note: Please contribute updates to this topic on TWiki.org at TWiki:TWiki.SearchPatternCookbook. |