Changeset 8369
- Timestamp:
- 07/31/10 08:22:19 (22 months ago)
- Location:
- trunk/core/data/System
- Files:
-
- 3 edited
-
FormattedSearch.txt (modified) (8 diffs)
-
InstantEnhancements.txt (modified) (5 diffs)
-
VarADDTOZONE.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/core/data/System/FormattedSearch.txt
r8367 r8369 214 214 ---+++ Nested Search 215 215 216 Search, as with almost any TML expression, may be nested. For example, search for some topics, then form a new search for each topic found in the first search. The idea is to build the nested search string using a formatted search in the first search.216 [[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. 217 217 218 218 #InsideOutLeftToRight … … 228 228 The macros are expanded in this order: MACRO3, MACRO4, MACRO2, MACRO1. 229 229 230 Consider the following example. Let's search for all topics that contain the word "culture" ( first search), and let's find out where each topic found is linked from (secondsearch).231 232 * Firstsearch:*230 Consider the following example. Let's search for all topics that contain the word "culture" (outer search), and find out where each topic found is linked from (inner search). 231 232 *Initial (outer) search:* 233 233 <verbatim class="tml"> 234 234 %SEARCH{ … … 239 239 }%</verbatim> 240 240 241 *Second search:*241 *Second (inner) search:* 242 242 243 243 For each hit, we want this search: 244 244 <verbatim class="tml"> 245 245 %SEARCH{ 246 "(topic found in firstsearch)"246 "(topic found in outer search)" 247 247 nosearch="on" 248 248 nototal="on" … … 253 253 Now let's nest the two. 254 254 ---++++ Method 1 (traditional) 255 The second search cannot be placed directly into the format string of the first, because of the "inside-out, left-to-right" macro expansion behaviour discussed earlier. It must be delayed so that the outer search is evaluated first. To do this, we need to escape the second search, i.e. let the first search build a series of searches using the secondsearch.256 * Use =$percent= to escape (delay) the secondsearch's [[VarSEARCH][SEARCH]] macro255 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. 256 * Use =$percent= to escape (delay) the inner search's [[VarSEARCH][SEARCH]] macro 257 257 * Use =\"= to escape the double quotes 258 258 * Use =$dollar= to escape the =$= of =$topic= … … 295 295 Nested expressions can be difficult to write correctly, and are difficult to troubleshoot when they go wrong. 296 296 297 The recommended approach is to make use of the [[VarSTARTSECTION][STARTSECTION]]/[[VarENDSECTION][ENDSECTION]] feature of the [[VarINCLUDE][INCLUDE]] macro. Instead of nesting the second search expression directly inside the format string of the first, the second search is written as a separate stand-alone section of a topic which is INCLUDEd into the format string of the first.297 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. 298 298 299 299 *Write this:* … … 308 308 }% 309 309 310 <!-- HTML comment to hide this section from the user 310 <!-- HTML comment to hide this section from the user. verbatim prevents the section being evaluated 311 <verbatim> 311 312 %STARTSECTION{"mysearch"}%%SEARCH{ 312 313 "%thetopic%" … … 316 317 separator=", " 317 318 }%%ENDSECTION{"mysearch"}% 319 </verbatim> 318 320 --> 319 321 </verbatim> … … 321 323 %ICON{"info"}% Output will be the same as for the first method 322 324 323 <blockquote>%ICON{"warning"}% Nested search can be slow, especially if you nest more then 3 times. Nesting is limited to 16 levels.325 <blockquote>%ICON{"warning"}% Nested search can be slow, especially if you nest more then 3 deep. Nesting is limited to 16 levels. 324 326 325 327 When using the traditional method for nesting macros, each new nesting level must "escape the escapes", e.g. write =$dollarpercentSEARCH{= for level three, =$dollardollarpercentSEARCH{= for level four, etc. Therefore it is strongly advised to use the sectional include method instead, which avoids this kind of difficult and error-prone syntax.</blockquote> -
trunk/core/data/System/InstantEnhancements.txt
r4884 r8369 64 64 65 65 For instance, if we want to write =%<nop>DOWN%= instead of =%<nop>ICON{"arrowbdown"}%=, define the new macro like this: 66 <verbatim>66 %JQREQUIRE{"chili"}%<verbatim class="tml"> 67 67 * Set DOWN = %ICON{"arrowbdown"}% 68 68 </verbatim> 69 69 Or if you have a custom image to use, attach this to [[%LOCALSITEPREFS%]] and write: 70 <verbatim>70 %JQREQUIRE{"chili"}%<verbatim class="tml"> 71 71 * Set DOWN = <img src="%ATTACHURL%/my_image.gif" border="0" alt="DOWN" width="16" height="16" /> 72 72 </verbatim> … … 115 115 ---+++ Personal directory of topics you're involved in 116 116 117 Here's how you can create your own personal directory of topics you've contributed to recently . Copy the text below (between *Start Copy* and *End Copy*) and paste it into your personal page (%WIKIUSERNAME%). You can add other webs to search by duplicating one of the web subsections and editing the string {web ="webname"} in the search parameters to refer to the specific web you want to search. This script would also work for a group.117 Here's how you can create your own personal directory of topics you've contributed to recently (assuming that your [[VarWIKIUSERNAME][username]] is present on topics that you contribute to). Copy the text below and paste it into your personal page (%WIKIUSERNAME%). You can add other webs to search by duplicating one of the web subsections and editing the string {web ="webname"} in the search parameters to refer to the specific web you want to search. 118 118 119 *Start Copy* 120 <verbatim> 119 <verbatim class="tml"> 121 120 *Here's a list of topics I've been involved in recently:* 122 121 123 122 ---++++ Project Web 123 %SEARCH{ 124 "%TOPIC%" 125 web="Project" 126 scope="text" 127 nonoise="on" 128 order="modified" 129 reverse="on" 130 limit="20" 131 }% 132 </verbatim> 124 133 125 %SEARCH{ "%TOPIC%" web="Project" scope="text" nosearch="on" nosummary="on" noheader="on" nototal="on" order="modified" reverse="on" limit="20"}% 126 127 </verbatim> 128 *End Copy* 129 130 The [[VarSEARCH][SEARCH macro]] has many more formatting options. 134 Read the [[VarSEARCH][SEARCH documentation]] for more about [[VarSEARCH][SEARCH]]. 131 135 132 136 ---+++ Recently changed pages 133 137 Here are the last 15 changed pages, formatted into a neat table. 134 138 135 <verbatim> 136 <table> 137 %SEARCH{ "'1'" scope="topic" type="query" nosearch="on" nototal="on" order="modified" reverse="on" format="<tr><td> [[$topic][$topic]] </td><td> $wikiusername </td><td> $date </td></tr>" limit="15" }% 138 </table> 139 <verbatim class="tml"> 140 %SEARCH{ 141 "1" 142 type="query" 143 nonoise="on" 144 order="modified" 145 reverse="on" 146 limit="15" 147 header="| *Topic* | *User* | *Date* |" 148 format="| [[$web.$topic][$topic]] | $wikiusername | $date |" 149 }% 139 150 </verbatim> 140 151 … … 142 153 143 154 When you're creating main gateway pages, you may want to temporarily (or permanently) restrict editing to yourself or a limited group of people. You can do this with a Preference setting that includes one or more users and groups. Only auhorized users will be able to use ==Edit==. 144 * *Example:* ==Set ALLOWTOPICCHANGE = <nop>%USERSWEB%.UserName, <nop>%USERSWEB%.GroupName==155 * *Example:* <verbatim class="tml"> * Set ALLOWTOPICCHANGE = %USERSWEB%.UserName, %USERSWEB%.GroupName</verbatim> 145 156 * %T% *To hide the setting:* Use HTML comment tags - put ==<!--== on the line _above the setting, and ==-->== on the line below. 146 157 … … 148 159 149 160 If you want to change the logo per web, simply attach a new logo.gif to the web's <nop>WebPreferences, and change the logo's filename by overriding the name using WEBLOGONAME in <nop>WebPreferences: 150 * =Set WEBLOGONAME = filename.gif= 161 <verbatim class="tml"> * Set WEBLOGONAME = filename.gif</verbatim> 151 162 152 163 Other cusomtisations are possible using =WEBLOGOIMG=, =WEBLOGOURL=, and =WEBLOGOALT= (they mirror the =WIKILOGO*= macros, but are applied to each web, rather than to the %<nop>WIKITOOLNAME%-based references) 153 164 154 165 If you'd like to have the same customised logo for all the webs, make these changes in %LOCALSITEPREFS% instead of each web's <nop>WebPreferences, e.g., 155 * =Set WEBLOGOIMG = %<nop>PUBURLPATH%/%USERSWEB%/WebPreferences/mylogo.gif= 166 <verbatim class="tml"> * Set WEBLOGOIMG = %PUBURLPATH%/%USERSWEB%/WebPreferences/mylogo.gif</verbatim> 156 167 157 168 ---++ Customize Topic Classification Forms … … 159 170 With a simple one or two-line default topic form available for every topic - in *Edit* mode, click the ==[Add]== button, and select the form if it isn't already enabled. Then, click the title to get to the actual form, ==[Edit]==, and carefully change values, probably basic page classifications. You'll get some increased value, and hands-on experience with DataForms, without having to read up about them first. %X% *(add the corresponding search per category - copy a default and change)* 160 171 172 ---++ Customize The Left Navigation Bar 173 <blockquote>%ICON{"info"}% This advice applies to sites using the default PatternSkin</blockquote> 174 175 Customize the contents of the WebLeftBar topic, which does not exist by default - read PatternSkinCustomization for details. Each web has its own WebLeftBar that may include important topics for that web, or link to an important topic for the overall site. 176 177 <blockquote>%T% Also check PatternSkinCustomization to learn how to customise the WebTopBar</blockquote> 161 178 162 179 ---++ Add Your Favorite <nop>JavaScript Features 163 180 164 You're no doubt familiar or better with HTML, JS, and "webmastering". Without getting into the [[skin templates]] system yet, you can easily edit the ==view.pattern.tmpl== (if you are using default pattern skin) (in the =templates= directory) for some dramatic effects. The top of the template is mostly regular HTML with some macros. Open up some space in the ==<head>== area, and you can drop in reliable <nop>JavaScripts - a pop-up window script, for example - or tag it as an external script.181 You're no doubt familiar or better with HTML, JS, and "webmastering". To add custom javascript and/or css to the page, the [[VarADDTOZONE][ADDTOZONE]] macro is used. Without getting into the [[skin templates]] system just yet, the easiest place to put [[VarADDTOZONE][ADDTOZONE]] macros is in some topic that is used by your site skin for every page view, such as the WebLeftBar if using the default PatternSkin. 165 182 166 * %T% Obviously, you can do the same - place a link to an external stylesheet as well. If you set values for standard HTML tags, you can control a good deal of the type size, style and color with out adding CSS tags. *example* 183 To add in-line javascript, read the [[VarADDTOZONE#ExampleAddingJS][javascript example]]. 167 184 168 %X% Depending on what you load up, you may change the overall cross-browser compatibility - however be careful that your site does not look beat up in various other browsers. The scripts you choose will determine compatibility. 185 Alternatively, make use of the =LIBJS= template, which simplifies the process of adding .js files to the page: 186 <verbatim class="tml"> 187 %TMPL:P{"LIBJS" id="MyJQueryPlugin/jquery.myplugin" requires="JQUERYPLUGIN"}% 188 </verbatim> 169 189 170 ---++ Customize The Left Navigation Bar 190 This assumes that there is a file named [[%PUBURLPATH%/%SYSTEMWEB%/MyJQueryPlugin/jquery.myplugin%FWSRC%.js]] 171 191 172 Customize the contents of the WebLeftBar for each web to include important topics for that web, or to link to an important topic for the overall site. Each web has its own WebLeftBar page. (This is specific to the PatternSkin.) 192 ---+++ Adding CSS 193 See [[VarADDTOZONE][ADDTOZONE]]'s [[VarADDTOZONE#ExampleAddingCSS][CSS example]] 194 195 %X% Depending on what you load up, you may change the overall cross-browser compatibility - be careful that your site does not look beat up in various other browsers. The scripts and CSS features you choose will determine compatibility. 173 196 174 197 ---- -
trunk/core/data/System/VarADDTOZONE.txt
r8347 r8369 74 74 By contrast, as explained earlier - when ={OptimizePageLayout}= is disabled (default) - Foswiki is able resolve such dependencies successfully. 75 75 76 #ExampleAddingJS 76 77 ---+++ Example: Adding Javascript to a page 77 78 * Make sure that all inline Javascript code in the topic (if it is allowed) … … 79 80 with the appropriate library-id to guarantee a correct load order. For example, jQuery code should be added as follows: 80 81 %JQREQUIRE{"chili"}%<verbatim class="js"> 81 %JQREQUIRE{"shake"}%%ADDTOZONE{82 "body"83 id="MyApp::ShakePart"84 text="85 <script type='text/javascript'>86 jQuery('#something').shake(3, 10, 180);87 </script>"88 requires="JQUERYPLUGIN::SHAKE"89 }%</verbatim> where "MyApp::ShakePart" is a unique =id= to identify the text added to body; and =JQUERYPLUGIN::SHAKE= signifies that the content added with that identifier should appear beforehand.82 %JQREQUIRE{"shake"}%%ADDTOZONE{ 83 "body" 84 id="MyApp::ShakePart" 85 text=" 86 <script type='text/javascript'> 87 jQuery('#something').shake(3, 10, 180); 88 </script>" 89 requires="JQUERYPLUGIN::SHAKE" 90 }%</verbatim> where "MyApp::ShakePart" is a unique =id= to identify the text added to body; and =JQUERYPLUGIN::SHAKE= signifies that the content added with that identifier should appear beforehand. 90 91 92 #ExampleAddingCSS 93 ---+++ Example: Adding CSS to a page 94 <verbatim class="tml"> 95 %ADDTOZONE{"head" 96 id="MyCSS" 97 text=" 98 <style type='text/css' media='all'> 99 @import url('%PUBURLPATH%/%SYSTEMWEB%/MyCSS/foo.css'); 100 </style>" 101 }% 102 </verbatim> 91 103 See also [[VarRENDERZONE][RENDERZONE]], 92 104 [[http://foswiki.org/Development/UsingADDTOZONE][Using ADDTOZONE]]
Note: See TracChangeset
for help on using the changeset viewer.
