Changeset 9329
- Timestamp:
- 09/25/10 09:12:13 (20 months ago)
- Location:
- branches/Release01x01/core/data/System
- Files:
-
- 3 edited
-
FormattedSearch.txt (modified) (10 diffs)
-
Macros.txt (modified) (12 diffs)
-
VarENCODE.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/Release01x01/core/data/System/FormattedSearch.txt
r9258 r9329 41 41 | =$nhits= | Number of hits if =multiple="on"=. Cumulative across all topics in current web. Identical to =$ntopics= unless =multiple="on"= | 42 42 | =$pager= | pager control - can be optionally customised using the =pagerformat= below | 43 %INCLUDE{ FormatTokens}%43 %INCLUDE{"FormatTokens"}% 44 44 45 45 <blockquote class="foswikiHelp">%X% Note that if the separator parameter for SEARCH is not defined a newline is added after the last search result.</blockquote> … … 64 64 | =$previousbutton= | skin template (SEARCH:pager_previous) html for the full URL to the previous page - _IF_ using the built in pager system | 65 65 | =$nextbutton= | skin template (SEARCH:pager_next) html for the full URL to the previous page - _IF_ using the built in pager system | 66 %INCLUDE{ FormatTokens}%66 %INCLUDE{"FormatTokens"}% 67 67 68 68 ---+++ 4. =format="..."= parameter … … 113 113 | =$nhits= | Number of hits if =multiple="on"=. Cumulative across all topics in current web. Identical to =$ntopics= unless =multiple="on"= | 114 114 | =$pager= | pager control - can be optionally customised using the =pagerformat= below | 115 %INCLUDE{ FormatTokens}%115 %INCLUDE{"FormatTokens"}% 116 116 117 117 ---++ Examples … … 187 187 #NestedSearch 188 188 ---+++ Nested Search 189 190 [[VarSEARCH][SEARCH]], as with many TML macros, may be nested. For example: search for some topics in an initial (outer) search, and for each of them apply a second (inner) search. The idea is to use the outer search to build a series of inner seraches. 191 192 %INCLUDE{"Macros" section="insideoutlefttoright" THETOPIC="%SYSTEMWEB%.FAQWhatIsWikiWiki" THEFIELD="TopicClassification"}% 189 [[VarSEARCH][SEARCH]] is one of many [[Macros][macros]] that produce output which may be controlled with =format=, =header= and =footer= parameters, among others. To make use of _additional_ macros in the output, familiarity with [[#InsideOutLeftToRight][inside-out, left-to-right]] order of expansion rules is required. There are two forms: 190 1 Standard: Use =%<nop>INNERMACRO%= to build the parameter string *before* =%<nop>OUTERMACRO%= is expanded 191 <verbatim class="tml"> %OUTERMACRO{ 192 format="%INNERMACRO%" 193 }%</verbatim> 194 1 Delayed: Use the parameter string to incorporate =%<nop>INNERMACRO%= into the output of =%<nop>OUTERMACRO%= 195 <verbatim class="tml"> %OUTERMACRO{ 196 format="$percentINNERMACRO$percent" 197 }%</verbatim> 198 <blockquote class="foswikiHelp">%T% When working with a given [[Macros][macro]], consult its documentation to determine which paramters support the =$percent/$percnt= [[FormatTokens][format tokens]]</blockquote> 199 200 %INCLUDE{"Macros" 201 section="insideoutlefttoright" 202 THETOPIC="%SYSTEMWEB%.FAQWhatIsWikiWiki" 203 THEFIELD="TopicClassification" 204 PARENT="UserDocumentationCategory" 205 }% 206 207 ---++++ Worked example 208 *Problem:* search for some topics in an initial (outer) search, and for each of them apply a second (inner) search. The idea is to use the outer search to build a series of inner seraches. 193 209 194 210 #NestedSearchExample … … 216 232 Now let's nest the two. 217 233 #NestingWithEscapes 218 ---++++ Method 1 (nesting with escapes)234 ---+++++ Method 1 (nesting with escapes) 219 235 The inner search cannot be placed directly into the format string of the outer, because of the "inside-out, left-to-right" macro expansion behaviour [[#InsideOutLeftToRight][discussed earlier]]. It must be delayed so that the outer search is evaluated first. To do this, we need to escape the inner search, i.e. let the outer search build a series of searches comprised of the inner search. 220 236 * Use =$percent= to escape (delay) the inner search's [[VarSEARCH][SEARCH]] macro … … 254 270 }% 255 271 272 <blockquote class="foswikiHelp"> 273 %X% When nesting with escapes, each new nesting level must "escape the escapes", e.g. write =$dollarpercentSEARCH{= for level three, =$dollardollarpercentSEARCH{= for level four, etc. 274 </blockquote> 275 256 276 #NestedSectionalInclude 257 ---++++ Method 2 (nesting with sectional includes)258 Nested expressions can be difficult to write correctly, and are difficult to troubleshoot when they go wrong.259 260 The recommended approach is to make use of the [[VarSTARTSECTION][STARTSECTION]]/[[VarENDSECTION][ENDSECTION]] feature of the [[VarINCLUDE][INCLUDE]] macro. Instead of nesting the inner search expression directly inside the format string of the outer, the inner search is written as a separate stand-alone section of a topic which is INCLUDEd into the format string of the outer.277 ---+++++ Method 2 (nesting with sectional includes) 278 Nested expressions with delayed macros can be difficult to write: care must be taken to escape all the quotes of the inner delayed macro, and it may become confusing whether to use =$topic=, =$dollartopic= or =$dollardollartopic=. 279 280 If you find yourself using escaped tokens like =$dollartopic=, another approach is to use the [[VarSTARTSECTION][STARTSECTION]]/[[VarENDSECTION][ENDSECTION]] feature of [[VarINCLUDE][INCLUDE]]. Instead of nesting the inner search expression directly inside the format string of the outer, the inner search is written as a separate stand-alone section of a topic which is INCLUDEd into the format string of the outer. 261 281 262 282 *Write this:* … … 288 308 <blockquote class="foswikiHelp">%H% Output will be the same as for the first method 289 309 290 %X% Nested search can be slow, especially if you nest more than 3 levels deep. Nesting is limited to 16 levels. 291 292 When nesting with escapes, each new nesting level must "escape the escapes", e.g. write =$dollarpercentSEARCH{= for level three, =$dollardollarpercentSEARCH{= for level four, etc. 293 294 Therefore the sectional include method is strongly recommended to avoid this kind of difficult syntax.</blockquote> 310 %X% Nested search can be slow, especially if you nest more than 3 levels deep. Nesting is limited to 16 levels.</blockquote> 295 311 296 312 ---+++ Most recently changed pages … … 319 335 }% 320 336 337 #ConditionalOutputExample 321 338 ---+++ Search with conditional output 322 339 … … 341 358 <blockquote class="foswikiHelp"> 342 359 %ICON{"info"}% *Details:* 343 * The SEARCH has a de ferred [[VarICON][ICON]]. The =$percent= ensures that ICON is evaluated once for each search hit344 * The [[VarICON][ICON]] contains an [[VarIF][IF]], which again is de ferred with the =$percent= token and will also be evaluated for each SEARCH hit. Additionally, the "inside-out, left-to-right"rule discussed earlier means that this IF expression will be evaluated before [[VarICON][ICON]].360 * The SEARCH has a delayed [[VarICON][ICON]]. The =$percent= ensures that ICON is evaluated once for each search hit 361 * The [[VarICON][ICON]] contains an [[VarIF][IF]], which again is delayed with the =$percent= token and will also be evaluated for each SEARCH hit. Additionally, the [[#InsideOutLeftToRight][inside-out, left-to-right]] rule discussed earlier means that this IF expression will be evaluated before [[VarICON][ICON]]. 345 362 * If =$topic= is a child of UserDocumentationCategory, the =info= icon is used; otherwise, =gear=. 346 363 </blockquote> … … 366 383 <verbatim class="tml"> 367 384 <form action="%SCRIPTURLPATH{"view"}%/%WEB%/%TOPIC%"> 368 Find Topics: 385 Find Topics: 369 386 <input type="text" name="q" size="32"\ 370 387 value="%URLPARAM{"q" encode="entity"}%" /> <input\ -
branches/Release01x01/core/data/System/Macros.txt
r9258 r9329 23 23 To use a macro type its name. For example, 24 24 * type =%<nop>T%= to get %T% (a [[%SYSTEMWEB%.PreferenceSettings][preference settings]]) 25 * type =%<nop>TOPIC%= to get =%TOPIC%= (a predefined [[ macro]])26 * type =%<nop>CALC{ "$UPPER(Text)" }%= to get =TEXT= ([[VarCALC][CALC]] is a macro defined by SpreadSheetPlugin)25 * type =%<nop>TOPIC%= to get =%TOPIC%= (a predefined [[VarTOPIC][macro]]) 26 * type =%<nop>CALC{ "$UPPER(Text)" }%= to get =TEXT= ([[VarCALC][CALC]] is a macro defined by [[SpreadSheetPlugin]]) 27 27 28 28 *Note:* … … 34 34 ---+++ Order of expansion 35 35 The following describes only these types of macros: 36 * Most built-in Foswiki macros. The following are notable exceptions: [[VarCALC][CALC]], [[VarSTARTSECTION][STARTSECTION]]/ENDSECTION, [[VarSTARTINCLUDE][STARTINCLUDE]]/STOPINCLUDE37 * Preference variables38 * Macros registered by most plugins, using the so-called [[PerlDoc?module=Foswiki::Func#registerTagHandler][registerTagHandler()]]39 40 But *not* plugins which rely on [[PerlDoc?module=Foswiki::Func#commonTagsHandler][commonTagsHandler()]] 36 * [[PreferenceSettings][Preference settings]] 37 * Most macros provided by plugins (those that use [[PerlDoc?module=Foswiki::Func#registerTagHandler][registerTagHandler()]]) 38 <blockquote class="foswikiHelp">%X% *Not* those that use [[PerlDoc?module=Foswiki::Func#commonTagsHandler][commonTagsHandler()]]</blockquote> 39 * Most built-in Foswiki macros 40 <blockquote class="foswikiHelp">%X% Notable exceptions include: [[VarCALC][CALC]], [[VarSTARTSECTION][STARTSECTION]]/ENDSECTION, [[VarSTARTINCLUDE][STARTINCLUDE]]/STOPINCLUDE</blockquote> 41 41 42 42 %STARTSECTION{"insideoutlefttoright"}% 43 #StandardForm 44 ---++++ Standard form 43 45 #InsideOutLeftToRight 44 The key to understanding nested expressions in Foswiki is to understand that macros are expanded "inside-out, left-to-right". For example: 46 The key to understanding nested expressions in Foswiki is to understand that macros are expanded "inside-out, left-to-right". *Example:* 47 45 48 <verbatim class="tml"> 46 49 %MACRO1{ … … 50 53 }% 51 54 </verbatim> 52 53 55 The macros are expanded in this order: MACRO3, MACRO4, MACRO2, MACRO1. 54 56 55 ---++++ Animated Example 57 #AnimatedExample 58 ---+++++ Animated Example 56 59 %JQREQUIRE{"CYCLE,EASING,CHILI"}%<!-- ids are appended with %INCLUDINGTOPIC% 57 60 to avoid duplicates in System.CompleteDocumentation -->%ADDTOZONE{"script" … … 72 75 requires="JQUERYPLUGIN::CYCLE" 73 76 }%%ADDTOZONE{"head" 74 id="NestedSlideshow /css"77 id="NestedSlideshow%INCLUDINGTOPIC%/css" 75 78 text="<style type='text/css'> 76 #NestedSlideshow%INCLUDINGTOPIC% { width: 440px; height: 249px; }77 #NestedSlideshowNav%INCLUDINGTOPIC% { z-index: 50; position: absolute; bottom: 10px; }78 79 #NestedSlideshowNav%INCLUDINGTOPIC% a { margin: 0 10px 0 0; padding: 3px 5px; border: 1px solid #ddd; background: #fff; text-decoration: none } 79 80 #NestedSlideshowNav%INCLUDINGTOPIC% a.activeSlide, … … 81 82 #NestedSlideshowNav%INCLUDINGTOPIC% a:focus { outline: none; } 82 83 </style>" 83 }%<div id="NestedSlideshow %INCLUDINGTOPIC%">84 <div id="NestedSlideshowNav%INCLUDINGTOPIC%"></div>84 }%<div id="NestedSlideshowNav%INCLUDINGTOPIC%"></div> 85 <div id="NestedSlideshow%INCLUDINGTOPIC%"> 85 86 <pre class="tml"> 86 87 %<nop>INCLUDE{ … … 106 107 %<nop>INCLUDE{ 107 108 "%<nop>QUERY{ 108 "'%<nop>SYSTEMWEB%.FAQWhatIsWikiWiki'/ %THEFIELD%"109 "'%<nop>SYSTEMWEB%.FAQWhatIsWikiWiki'/TopicClassification" 109 110 }%" 110 111 section="Summary" … … 116 117 %<nop>INCLUDE{ 117 118 "%<nop>QUERY{ 118 "'%SYSTEMWEB%.FAQWhatIsWikiWiki'/ %THEFIELD%"119 "'%SYSTEMWEB%.FAQWhatIsWikiWiki'/TopicClassification" 119 120 }%" 120 121 section="Summary" … … 126 127 %<nop>INCLUDE{ 127 128 "%QUERY{ 128 "'%SYSTEMWEB%.FAQWhatIsWikiWiki'/ %THEFIELD%"129 "'%SYSTEMWEB%.FAQWhatIsWikiWiki'/TopicClassification" 129 130 }%" 130 131 section="Summary" … … 136 137 %INCLUDE{ 137 138 "%QUERY{ 138 "'%SYSTEMWEB%.FAQWhatIsWikiWiki'/ %THEFIELD%"139 "'%SYSTEMWEB%.FAQWhatIsWikiWiki'/TopicClassification" 139 140 }%" 140 141 section="Summary" … … 146 147 %INCLUDE{ 147 148 "%QUERY{ 148 "'%SYSTEMWEB%.FAQWhatIsWikiWiki'/ %THEFIELD%"149 "'%SYSTEMWEB%.FAQWhatIsWikiWiki'/TopicClassification" 149 150 }%" 150 151 section="Summary" … … 152 153 * Set THETOPIC = %SYSTEMWEB%.FAQWhatIsWikiWiki 153 154 * Set THEFIELD = TopicClassification 155 </pre> 156 </div> 157 158 #DelayedForm 159 ---++++ Delayed form 160 [[#StandardForm][Standard form]] macros can nearly always be used to build the parameter string of another macro; however, sometimes it is desirable to bypass the [[#InsideOutLeftToRight][inside-out]] expansion order and delay the inner macro until after the outer macro has finished expansion. This is accomplished by using the [[FormatTokens][$percent]] format token instead of =%=, and escaping any ="= character it uses (becomes =\"=) 161 162 <blockquote class="foswikiHelp">%T% When working with a given [[Macros][macro]], consult its documentation to determine which paramters support the =$percent/$percnt= [[FormatTokens][format tokens]]. Generally only _output parameters_ like =header=, =format= and =footer= support [[FormatTokens][format tokens]].</blockquote> 163 *Example:* 164 <verbatim class="tml"> 165 %MACRO1{ 166 format="$percentMACRO2{ 167 format=\"%MACRO3%, %MACRO4%\" 168 }$percent" 169 }% 170 </verbatim> 171 The macros are expanded in this order: MACRO3, MACRO4, MACRO1, *MACRO2*. 172 #AnimatedDelayedExample 173 ---+++++ Animated Example 174 From the [[FormattedSearch#ConditionalOutputExample][conditional output example]]: 175 176 %JQREQUIRE{"CYCLE,EASING,CHILI"}%<!-- ids are appended with %INCLUDINGTOPIC% 177 to avoid duplicates in System.CompleteDocumentation -->%ADDTOZONE{"script" 178 id="DelayedSlideshow%INCLUDINGTOPIC%" 179 text="<script type='text/javascript'> 180 jQuery(document).ready(function($) { 181 $('#DelayedSlideshow%INCLUDINGTOPIC%').cycle({ 182 fx: 'fade', 183 speed: 'slow', 184 timeout: 5000, 185 pager: '#DelayedSlideshowNav%INCLUDINGTOPIC%', 186 slideExpr: 'pre', 187 pause: true, 188 pauseOnPagerHover: true 189 }); 190 }); 191 </script>" 192 requires="JQUERYPLUGIN::CYCLE" 193 }%%ADDTOZONE{"head" 194 id="DelayedSlideshow%INCLUDINGTOPIC%/css" 195 text="<style type='text/css'> 196 #DelayedSlideshowNav%INCLUDINGTOPIC% a { margin: 0 10px 0 0; padding: 3px 5px; border: 1px solid #ddd; background: #fff; text-decoration: none } 197 #DelayedSlideshowNav%INCLUDINGTOPIC% a.activeSlide, 198 #DelayedSlideshowNav%INCLUDINGTOPIC% a:hover { background: #cff } 199 #DelayedSlideshowNav%INCLUDINGTOPIC% a:focus { outline: none; } 200 </style>" 201 }%<div id="DelayedSlideshowNav%INCLUDINGTOPIC%"></div> 202 <div id="DelayedSlideshow%INCLUDINGTOPIC%"> 203 <verbatim class="tml"> 204 %SEARCH{ 205 "info.date >= d2n('2009-01-01') AND info.date <= d2n('2009-12-31')" 206 type="query" 207 limit="2" 208 nonoise="on" 209 format=" * $percentICON{ 210 \"$percentIF{ 211 \"'$topic'/parent.name='%PARENT%'\" 212 then=\"info\" else=\"gear\" 213 }$percent\" 214 }$percent [[$topic]]" 215 }% 216 ---- 217 * Set PARENT = UserDocumentationCategory 218 </verbatim> 219 <pre class="tml"> 220 %<nop>SEARCH{ 221 "info.date >= d2n('2009-01-01') AND info.date <= d2n('2009-12-31')" 222 type="query" 223 limit="2" 224 nonoise="on" 225 format=" * $percentICON{ 226 \"$percentIF{ 227 \"'$topic'/parent.name='UserDocumentationCategory'\" 228 then=\"info\" else=\"gear\" 229 }$percent\" 230 }$percent [[$topic]]" 231 }% 232 ---- 233 * Set PARENT = UserDocumentationCategory 234 </pre> 235 <pre class="tml"> 236 %SEARCH{ 237 "info.date >= d2n('2009-01-01') AND info.date <= d2n('2009-12-31')" 238 type="query" 239 limit="2" 240 nonoise="on" 241 format=" * $percent<nop>ICON{ 242 \"$percent<nop>IF{ 243 \"'$topic'/parent.name='UserDocumentationCategory'\" 244 then=\"info\" else=\"gear\" 245 }$percent\" 246 }$percent [[$topic]]" 247 }% 248 ---- 249 * Set PARENT = UserDocumentationCategory 250 </pre> 251 <pre class="tml"> 252 %SEARCH{ 253 "info.date >= d2n('2009-01-01') AND info.date <= d2n('2009-12-31')" 254 type="query" 255 limit="2" 256 nonoise="on" 257 format=" * $percent<nop>ICON{ 258 \"$percentIF{ 259 \"'$topic'/parent.name='UserDocumentationCategory'\" 260 then=\"info\" else=\"gear\" 261 }$percent\" 262 }$percent [[$topic]]" 263 }% 264 ---- 265 * Set PARENT = UserDocumentationCategory 266 </pre> 267 <pre class="tml"> 268 %SEARCH{ 269 "info.date >= d2n('2009-01-01') AND info.date <= d2n('2009-12-31')" 270 type="query" 271 limit="2" 272 nonoise="on" 273 format=" * <img src=\"$percentICONURL{ 274 \"$percentIF{ 275 \"'$topic'/parent.name='UserDocumentationCategory'\" 276 then=\"info\" else=\"gear\" 277 }$percent\" 278 }$percent\"/> [[$topic]]" 279 }% 280 ---- 281 * Set PARENT = UserDocumentationCategory 154 282 </pre> 155 283 </div> … … 217 345 *Related Topics:* UserDocumentationCategory 218 346 <!-- %JQREQUIRE{"chili"}% --> 219 220 %META:FILEATTACHMENT{name="nested_macros.gif" attr="h" version="1.1"}% -
branches/Release01x01/core/data/System/VarENCODE.txt
r9226 r9329 25 25 %<nop>ENCODE{"spaced name"}%= expands to 26 26 %ENCODE{"spaced name"}% 27 %<nop>ENCODE{"| Blah | | More blah |" old="|,$n" new="& vbar;,<br />"}% expands to28 %ENCODE{"| Blah | | More blah |" old="|,$n" new="& vbar;,<br />"}%27 %<nop>ENCODE{"| Blah | | More blah |" old="|,$n" new="&#124;,<br />"}% expands to 28 %ENCODE{"| Blah | | More blah |" old="|,$n" new="|,<br />"}% 29 29 - this encoding is useful to protect special TML characters in tables. 30 30 %<nop>ENCODE{"10xx1x01x" old="1,x,0" new="A,,B"}% expands to
Note: See TracChangeset
for help on using the changeset viewer.
