Changeset 6989
- Timestamp:
- 03/29/10 09:26:39 (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Release01x00/core/data/System/SearchPatternCookbook.txt
r1985 r6989 26 26 How to extract the 'name' values, i.e. 'option1', 'option2' and 'option3' and put them in a HTML form select input? 27 27 28 ---+++ Solution 29 28 ---+++ Solution 1 30 29 The following search pattern can be employed: 31 30 … … 33 32 <form> 34 33 <select> 35 %SEARCH{ "^\|[^\|]*\| *option *\|" topic="%TOPIC%" type="regex" multiple="on" nosearch="on" nototal="on" format="<option>$pattern(^\| *(.*?) *\|.*)</option>" }% 34 %SEARCH{ 35 "^\|[^\|]*\| *option *\|" 36 topic="%TOPIC%" 37 type="regex" 38 multiple="on" 39 nosearch="on" 40 nototal="on" 41 format="<option>$pattern(^\| *(.*?) *\|.*)</option>" 42 }% 36 43 </select> 37 44 </form> … … 41 48 <form> 42 49 <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 *\|" 52 topic="%TOPIC%" 53 type="regex" 54 multiple="on" 55 nosearch="on" 56 nototal="on" 57 format="<option>$pattern(^\| *(.*?) *\|.*)</option>" 58 }% 59 </select> 60 </form> 61 46 62 47 63 … … 70 86 71 87 <verbatim> 72 %SEARCH{"TopicClassification='%URLPARAM{type}%'" type="query" nosearch="on" 88 %SEARCH{ 89 "TopicClassification='%URLPARAM{type}%'" 90 type="query" 91 nosearch="on" 73 92 format=" * $topic - <font face=\"arial,helvetica\" size=\"1\"> 74 93 _last modified by_ $wikiusername _on_ $date </font> %BR% 75 94 <font face=\"arial,helvetica\" size=\"1\"> $formfield(TopicStatus) </font>" 76 sort="topic"}% 95 sort="topic" 96 }% 77 97 </verbatim> 78 98 … … 84 104 <form name="selectType" action="%SCRIPTURLPATH{"view"}%/%WEB%/" > 85 105 <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 *\|" 108 topic="TopicClassification" 109 web="%WEB%" 110 type="regex" 111 multiple="on" 112 nosearch="on" 113 nototal="on" 114 format="<option value=%BASETOPIC%?type=$pattern(^\| *(.*?) *\|.*)>$pattern(^\| *(.*?) *\|.*)</option>" 115 }% 116 <option value=%BASETOPIC%>All pages</option> 117 </select> 89 118 </form> 90 119 %STOPSIDEBAR% … … 108 137 =%<nop>META{ "parent" dontrecurse="on" }%= 109 138 139 ---+++ Test case 140 141 %META{ "parent" dontrecurse="on" }% 142 110 143 111 144 <!-- ============================== --> … … 123 156 <verbatim> 124 157 Children: 125 %SEARCH{ "parent.name='%TOPIC%'" type="query" nonoise="on" format="[[$topic]]" separator=", " }% 158 %SEARCH{ 159 "parent.name='%TOPIC%'" 160 type="query" 161 nonoise="on" 162 format="[[$topic]]" 163 separator=", " 164 }% 126 165 </verbatim> 127 166 128 167 *Note:* Replace =%<nop>TOPIC%= with =%<nop>BASETOPIC%= if you put this SEARCH into the skin or a sidebar. 129 168 169 See also HierarchicalNavigation for an elaborate example. 130 170 131 171 <!-- ============================== --> … … 143 183 <select name="topic"> 144 184 <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%" 187 scope="topic" 188 web="all" 189 topic="%HOMETOPIC%" 190 format="<option value=\"$web.$topic\">$web</option>" 191 separator=" " 192 }% 193 </select> 194 <input type="submit" class="foswikiSubmit" value="Go" /> 148 195 </form> 149 196 </verbatim> … … 156 203 <select name="topic"> 157 204 <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%" 207 scope="topic" 208 web="all" 209 topic="%HOMETOPIC%" 210 format="<option value=\"$web.$topic\">$web</option>" 211 separator=" " 212 }% 213 </select> 214 <input type="submit" class="foswikiSubmit" value="Go" /> 161 215 </form> 162 216 … … 183 237 <select name="type"> 184 238 <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*.*?" 241 topic="CategoryList" 242 type="regex" 243 multiple="on" 244 casesensitive="on" 245 nosummary="on" 246 nosearch="on" 247 noheader="on" 248 nototal="on" 249 format="<option>$pattern(.* \*\s*([^\n]*).*)</option>" 250 }% 186 251 </select> 187 252 </verbatim> … … 189 254 To render the bullet list as a comma-separated list, use the =separator= parameter: 190 255 <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*.*?" 258 topic="CategoryList" 259 type="regex" 260 multiple="on" 261 casesensitive="on" 262 nosummary="on" 263 nosearch="on" 264 noheader="on" 265 nototal="on" 266 separator="," 267 format="$pattern(.* \*\s*([^\n]*).*)" 268 }% 192 269 </verbatim> 193 270 … … 206 283 207 284 <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:" 287 topic="%TOPIC%" 288 type="regex" 289 casesensitive="on" 290 nosummary="on" 291 nosearch="on" 292 noheader="on" 293 nototal="on" 294 format="---+!! $pattern(.* \* Name: ([^\n]*).*)" 295 }% 209 296 </verbatim> 210 297 … … 217 304 Search result: 218 305 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:" 308 topic="%TOPIC%" 309 type="regex" 310 casesensitive="on" 311 nosummary="on" 312 nosearch="on" 313 noheader="on" 314 nototal="on" 315 format="<strong>$pattern(.* \* Name: ([^\n]*).*)</strong>" 316 }% 220 317 221 318 <!-- ============================== --> … … 231 328 Search for the 'moved' meta data. Type this: 232 329 233 =Moved topics: %<nop>SEARCH{ "moved.to!=''" type="query" format="$topic, " nosearch="on" noheader="on" nosummary="on" }%= 330 <verbatim> 331 Moved topics: %SEARCH{ 332 "moved.to!=''" 333 web="all" 334 type="query" 335 separator=", " 336 format="$web.$topic" 337 nonoise="on" 338 noheader="on" 339 nosummary="on" 340 }% 341 </verbatim> 342 343 ---+++ Test case 344 Moved topics: %SEARCH{ 345 "moved.to!=''" 346 web="all" 347 type="query" 348 separator=", " 349 format="$web.$topic" 350 nonoise="on" 351 noheader="on" 352 nosummary="on" 353 }% 234 354 235 355 --- 236 356 *Related Topics:* UserDocumentationCategory, SearchHelp, [[Macros]], FormattedSearch, RegularExpression 237 357 358
Note: See TracChangeset
for help on using the changeset viewer.
