Changeset 6989


Ignore:
Timestamp:
03/29/10 09:26:39 (2 years ago)
Author:
ArthurClemens
Message:

Item8795: fix a number of issus:
at least one of the searches does not work
css class missing
SEARCHes can be written more clearly by having each parameter on a new line

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Release01x00/core/data/System/SearchPatternCookbook.txt

    r1985 r6989  
    2626How to extract the 'name' values, i.e. 'option1', 'option2' and 'option3' and put them in a HTML form select input? 
    2727 
    28 ---+++ Solution 
    29  
     28---+++ Solution 1 
    3029The following search pattern can be employed: 
    3130 
     
    3332<form> 
    3433<select> 
    35 %SEARCH{ "^\|[^\|]*\| *option *\|" topic="%TOPIC%" type="regex" multiple="on" nosearch="on" nototal="on" format="<option>$pattern(^\| *(.*?) *\|.*)</option>" }% 
     34%SEARCH{ 
     35"^\|[^\|]*\| *option *\|" 
     36topic="%TOPIC%" 
     37type="regex" 
     38multiple="on" 
     39nosearch="on" 
     40nototal="on" 
     41format="<option>$pattern(^\| *(.*?) *\|.*)</option>" 
     42}% 
    3643</select> 
    3744</form> 
     
    4148<form> 
    4249<select> 
    43 %SEARCH{ "^\|[^\|]*\| *option *\|" topic="%TOPIC%" type="regex" multiple="on" nosearch="on" nototal="on" format="<option>$pattern(^\| *(.*?) *\|.*)</option>" }% 
    44 </select> 
    45 </form> 
     50%SEARCH{ 
     51"^\|[^\|]*\| *option *\|" 
     52topic="%TOPIC%" 
     53type="regex" 
     54multiple="on" 
     55nosearch="on" 
     56nototal="on" 
     57format="<option>$pattern(^\| *(.*?) *\|.*)</option>" 
     58}% 
     59</select> 
     60</form> 
     61 
    4662 
    4763 
     
    7086 
    7187<verbatim> 
    72 %SEARCH{"TopicClassification='%URLPARAM{type}%'" type="query" nosearch="on"  
     88%SEARCH{ 
     89"TopicClassification='%URLPARAM{type}%'" 
     90type="query" 
     91nosearch="on"  
    7392format="   * $topic - <font face=\"arial,helvetica\" size=\"1\">  
    7493_last modified by_ $wikiusername _on_ $date </font> %BR% &nbsp;&nbsp;&nbsp;  
    7594<font face=\"arial,helvetica\" size=\"1\"> $formfield(TopicStatus) </font>"  
    76 sort="topic"}% 
     95sort="topic" 
     96}% 
    7797</verbatim> 
    7898 
     
    84104<form name="selectType" action="%SCRIPTURLPATH{"view"}%/%WEB%/" > 
    85105<select name="type" size="1" onchange="document.location=this.value;">  
    86 %SEARCH{ "^\|[^\|]*\| *option *\|" topic="TopicClassification" web="%WEB%" type="regex"  
    87 multiple="on" nosearch="on" nototal="on" format="<option value=%BASETOPIC%?type=$pattern(^\| *(.*?) *\|.*)>$pattern(^\| *(.*?) *\|.*)</option>" }%  
    88 <option value=%BASETOPIC%>All pages</option> </select> 
     106%SEARCH{ 
     107"^\|[^\|]*\| *option *\|" 
     108topic="TopicClassification" 
     109web="%WEB%" 
     110type="regex"  
     111multiple="on" 
     112nosearch="on" 
     113nototal="on" 
     114format="<option value=%BASETOPIC%?type=$pattern(^\| *(.*?) *\|.*)>$pattern(^\| *(.*?) *\|.*)</option>" 
     115}%  
     116<option value=%BASETOPIC%>All pages</option> 
     117</select> 
    89118</form> 
    90119%STOPSIDEBAR%  
     
    108137=%<nop>META{ "parent" dontrecurse="on" }%= 
    109138 
     139---+++ Test case 
     140 
     141%META{ "parent" dontrecurse="on" }% 
     142 
    110143 
    111144<!-- ============================== --> 
     
    123156<verbatim> 
    124157Children: 
    125 %SEARCH{ "parent.name='%TOPIC%'" type="query" nonoise="on" format="[[$topic]]" separator=", " }% 
     158%SEARCH{ 
     159"parent.name='%TOPIC%'" 
     160type="query" 
     161nonoise="on" 
     162format="[[$topic]]" 
     163separator=", " 
     164}% 
    126165</verbatim> 
    127166 
    128167*Note:* Replace =%<nop>TOPIC%= with =%<nop>BASETOPIC%= if you put this SEARCH into the skin or a sidebar. 
    129168 
     169See also HierarchicalNavigation for an elaborate example. 
    130170 
    131171<!-- ============================== --> 
     
    143183<select name="topic"> 
    144184<option value="%TOPIC%">Select...</option> 
    145 %SEARCH{ "%HOMETOPIC%" scope="topic" web="all" topic="%HOMETOPIC%" format="<option value=\"$web.$topic\">$web</option>" separator=" " }% 
    146 </select> 
    147 <input type="submit"  value="Go" /> 
     185%SEARCH{ 
     186"%HOMETOPIC%" 
     187scope="topic" 
     188web="all" 
     189topic="%HOMETOPIC%" 
     190format="<option value=\"$web.$topic\">$web</option>" 
     191separator=" " 
     192}% 
     193</select> 
     194<input type="submit" class="foswikiSubmit" value="Go" /> 
    148195</form> 
    149196</verbatim> 
     
    156203<select name="topic"> 
    157204<option value="%TOPIC%">Select...</option> 
    158 %WEBLIST{ format="<option value=\"$name.%HOMETOPIC%\">$name</option>" webs="public" separator=" " }% 
    159 </select> 
    160 <input type="submit" value="Go" /> 
     205%SEARCH{ 
     206"%HOMETOPIC%" 
     207scope="topic" 
     208web="all" 
     209topic="%HOMETOPIC%" 
     210format="<option value=\"$web.$topic\">$web</option>" 
     211separator=" " 
     212}% 
     213</select> 
     214<input type="submit" class="foswikiSubmit" value="Go" /> 
    161215</form> 
    162216 
     
    183237<select name="type"> 
    184238<option>Select category...</option> 
    185 %SEARCH{"   *\s*.*?" topic="CategoryList" type="regex" multiple="on" casesensitive="on" nosummary="on" nosearch="on" noheader="on" nototal="on" format="<option>$pattern(.*   \*\s*([^\n]*).*)</option>"}% 
     239%SEARCH{ 
     240"   *\s*.*?" 
     241topic="CategoryList" 
     242type="regex" 
     243multiple="on" 
     244casesensitive="on" 
     245nosummary="on" 
     246nosearch="on" 
     247noheader="on" 
     248nototal="on" 
     249format="<option>$pattern(.*   \*\s*([^\n]*).*)</option>" 
     250}% 
    186251</select> 
    187252</verbatim> 
     
    189254To render the bullet list as a comma-separated list, use the =separator= parameter: 
    190255<verbatim> 
    191 %SEARCH{"   *\s*.*?" topic="CategoryList" type="regex" multiple="on" casesensitive="on" nosummary="on" nosearch="on" noheader="on" nototal="on" separator="," format="$pattern(.*   \*\s*([^\n]*).*)"}% 
     256%SEARCH{ 
     257"   *\s*.*?" 
     258topic="CategoryList" 
     259type="regex" 
     260multiple="on" 
     261casesensitive="on" 
     262nosummary="on" 
     263nosearch="on" 
     264noheader="on" 
     265nototal="on" 
     266separator="," 
     267format="$pattern(.*   \*\s*([^\n]*).*)" 
     268}% 
    192269</verbatim> 
    193270 
     
    206283 
    207284<verbatim> 
    208 %SEARCH{"   * [N]ame: " topic="%TOPIC%" type="regex" casesensitive="on" nosummary="on" nosearch="on" noheader="on" nototal="on" format="---+!! $pattern(.*   \* Name: ([^\n]*).*)"}% 
     285%SEARCH{ 
     286"   \* [N]ame:" 
     287topic="%TOPIC%" 
     288type="regex" 
     289casesensitive="on" 
     290nosummary="on" 
     291nosearch="on" 
     292noheader="on" 
     293nototal="on" 
     294format="---+!! $pattern(.*   \* Name: ([^\n]*).*)" 
     295}% 
    209296</verbatim> 
    210297 
     
    217304Search result: 
    218305 
    219 %SEARCH{"   * [N]ame: " topic="%TOPIC%" type="regex" casesensitive="on" nosummary="on" nosearch="on" noheader="on" nototal="on" format="---+!! $pattern(.*   \* Name: ([^\n]*).*)"}% 
     306%SEARCH{ 
     307"   \* [N]ame:" 
     308topic="%TOPIC%" 
     309type="regex" 
     310casesensitive="on" 
     311nosummary="on" 
     312nosearch="on" 
     313noheader="on" 
     314nototal="on" 
     315format="<strong>$pattern(.*   \* Name: ([^\n]*).*)</strong>" 
     316}% 
    220317 
    221318<!-- ============================== --> 
     
    231328Search for the 'moved' meta data. Type this:  
    232329 
    233 =Moved topics: %<nop>SEARCH{ "moved.to!=''" type="query" format="$topic, " nosearch="on" noheader="on" nosummary="on" }%= 
     330<verbatim> 
     331Moved topics: %SEARCH{ 
     332"moved.to!=''" 
     333web="all" 
     334type="query" 
     335separator=", " 
     336format="$web.$topic" 
     337nonoise="on" 
     338noheader="on" 
     339nosummary="on" 
     340}% 
     341</verbatim> 
     342 
     343---+++ Test case 
     344Moved topics: %SEARCH{ 
     345"moved.to!=''" 
     346web="all" 
     347type="query" 
     348separator=", " 
     349format="$web.$topic" 
     350nonoise="on" 
     351noheader="on" 
     352nosummary="on" 
     353}% 
    234354 
    235355--- 
    236356*Related Topics:* UserDocumentationCategory, SearchHelp, [[Macros]], FormattedSearch, RegularExpression 
    237357 
     358 
Note: See TracChangeset for help on using the changeset viewer.