Changeset 6990
- Timestamp:
- 03/29/10 09:26:58 (2 years ago)
- File:
-
- 1 edited
-
trunk/core/data/System/SearchPatternCookbook.txt (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/core/data/System/SearchPatternCookbook.txt
r1985 r6990 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 62 ---+++ Solution 2 63 If your table has this format: 64 <verbatim> 65 | *Country* | 66 | | 67 | Afghanistan | 68 | Aland Islands | 69 | Albania | 70 | Algeria | 71 | American Samoa | 72 | Andorra | 73 </verbatim> 74 75 You need to skip the header row. Use this search: 76 <verbatim> 77 <select> 78 %SEARCH{ 79 "^\|[^\*\|]*\|" 80 topic="CountryList" 81 type="regex" 82 multiple="on" 83 nosearch="on" 84 nototal="on" 85 format="<option>$pattern(^\| *(.*?) *\|.*)</option>" 86 }% 87 </select> 88 </verbatim> 89 90 Which renders as: 91 92 <select> 93 %SEARCH{ 94 "^\|[^\*\|]*\|" 95 topic="CountryList" 96 type="regex" 97 multiple="on" 98 nosearch="on" 99 nototal="on" 100 format="<option>$pattern(^\| *(.*?) *\|.*)</option>" 101 }% 102 </select> 103 46 104 47 105 … … 70 128 71 129 <verbatim> 72 %SEARCH{"TopicClassification='%URLPARAM{type}%'" type="query" nosearch="on" 130 %SEARCH{ 131 "TopicClassification='%URLPARAM{type}%'" 132 type="query" 133 nosearch="on" 73 134 format=" * $topic - <font face=\"arial,helvetica\" size=\"1\"> 74 135 _last modified by_ $wikiusername _on_ $date </font> %BR% 75 136 <font face=\"arial,helvetica\" size=\"1\"> $formfield(TopicStatus) </font>" 76 sort="topic"}% 137 sort="topic" 138 }% 77 139 </verbatim> 78 140 … … 84 146 <form name="selectType" action="%SCRIPTURLPATH{"view"}%/%WEB%/" > 85 147 <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> 148 %SEARCH{ 149 "^\|[^\|]*\| *option *\|" 150 topic="TopicClassification" 151 web="%WEB%" 152 type="regex" 153 multiple="on" 154 nosearch="on" 155 nototal="on" 156 format="<option value=%BASETOPIC%?type=$pattern(^\| *(.*?) *\|.*)>$pattern(^\| *(.*?) *\|.*)</option>" 157 }% 158 <option value=%BASETOPIC%>All pages</option> 159 </select> 89 160 </form> 90 161 %STOPSIDEBAR% … … 108 179 =%<nop>META{ "parent" dontrecurse="on" }%= 109 180 181 ---+++ Test case 182 183 %META{ "parent" dontrecurse="on" }% 184 110 185 111 186 <!-- ============================== --> … … 123 198 <verbatim> 124 199 Children: 125 %SEARCH{ "parent.name='%TOPIC%'" type="query" nonoise="on" format="[[$topic]]" separator=", " }% 200 %SEARCH{ 201 "parent.name='%TOPIC%'" 202 type="query" 203 nonoise="on" 204 format="[[$topic]]" 205 separator=", " 206 }% 126 207 </verbatim> 127 208 128 209 *Note:* Replace =%<nop>TOPIC%= with =%<nop>BASETOPIC%= if you put this SEARCH into the skin or a sidebar. 129 210 211 See also HierarchicalNavigation for an elaborate example. 130 212 131 213 <!-- ============================== --> … … 143 225 <select name="topic"> 144 226 <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" /> 227 %SEARCH{ 228 "%HOMETOPIC%" 229 scope="topic" 230 web="all" 231 topic="%HOMETOPIC%" 232 format="<option value=\"$web.$topic\">$web</option>" 233 separator=" " 234 }% 235 </select> 236 <input type="submit" class="foswikiSubmit" value="Go" /> 148 237 </form> 149 238 </verbatim> … … 156 245 <select name="topic"> 157 246 <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" /> 247 %SEARCH{ 248 "%HOMETOPIC%" 249 scope="topic" 250 web="all" 251 topic="%HOMETOPIC%" 252 format="<option value=\"$web.$topic\">$web</option>" 253 separator=" " 254 }% 255 </select> 256 <input type="submit" class="foswikiSubmit" value="Go" /> 161 257 </form> 162 258 … … 183 279 <select name="type"> 184 280 <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>"}% 281 %SEARCH{ 282 " *\s*.*?" 283 topic="CategoryList" 284 type="regex" 285 multiple="on" 286 casesensitive="on" 287 nosummary="on" 288 nosearch="on" 289 noheader="on" 290 nototal="on" 291 format="<option>$pattern(.* \*\s*([^\n]*).*)</option>" 292 }% 186 293 </select> 187 294 </verbatim> … … 189 296 To render the bullet list as a comma-separated list, use the =separator= parameter: 190 297 <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]*).*)"}% 298 %SEARCH{ 299 " *\s*.*?" 300 topic="CategoryList" 301 type="regex" 302 multiple="on" 303 casesensitive="on" 304 nosummary="on" 305 nosearch="on" 306 noheader="on" 307 nototal="on" 308 separator="," 309 format="$pattern(.* \*\s*([^\n]*).*)" 310 }% 192 311 </verbatim> 193 312 … … 206 325 207 326 <verbatim> 208 %SEARCH{" * [N]ame: " topic="%TOPIC%" type="regex" casesensitive="on" nosummary="on" nosearch="on" noheader="on" nototal="on" format="---+!! $pattern(.* \* Name: ([^\n]*).*)"}% 327 %SEARCH{ 328 " \* [N]ame:" 329 topic="%TOPIC%" 330 type="regex" 331 casesensitive="on" 332 nosummary="on" 333 nosearch="on" 334 noheader="on" 335 nototal="on" 336 format="---+!! $pattern(.* \* Name: ([^\n]*).*)" 337 }% 209 338 </verbatim> 210 339 … … 217 346 Search result: 218 347 219 %SEARCH{" * [N]ame: " topic="%TOPIC%" type="regex" casesensitive="on" nosummary="on" nosearch="on" noheader="on" nototal="on" format="---+!! $pattern(.* \* Name: ([^\n]*).*)"}% 348 %SEARCH{ 349 " \* [N]ame:" 350 topic="%TOPIC%" 351 type="regex" 352 casesensitive="on" 353 nosummary="on" 354 nosearch="on" 355 noheader="on" 356 nototal="on" 357 format="<strong>$pattern(.* \* Name: ([^\n]*).*)</strong>" 358 }% 220 359 221 360 <!-- ============================== --> … … 231 370 Search for the 'moved' meta data. Type this: 232 371 233 =Moved topics: %<nop>SEARCH{ "moved.to!=''" type="query" format="$topic, " nosearch="on" noheader="on" nosummary="on" }%= 372 <verbatim> 373 Moved topics: %SEARCH{ 374 "moved.to!=''" 375 web="all" 376 type="query" 377 separator=", " 378 format="$web.$topic" 379 nonoise="on" 380 noheader="on" 381 nosummary="on" 382 }% 383 </verbatim> 384 385 ---+++ Test case 386 Moved topics: %SEARCH{ 387 "moved.to!=''" 388 web="all" 389 type="query" 390 separator=", " 391 format="$web.$topic" 392 nonoise="on" 393 noheader="on" 394 nosummary="on" 395 }% 234 396 235 397 ---
Note: See TracChangeset
for help on using the changeset viewer.
