Changeset 702
- Timestamp:
- 11/15/08 13:21:07 (4 years ago)
- File:
-
- 1 edited
-
trunk/core/data/TWiki/Macros.txt (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/core/data/TWiki/Macros.txt
r696 r702 7 7 8 8 Macros are text strings - =%<nop>MACRONAME%= or =%<nop>MACRONAME{ parameter="value" }%= - that expand into content whenever a topic is rendered for viewing. There are two types of macros: 9 1 Preference s macros: Can be defined and changed by the user9 1 Preference settings: Can be defined and changed by the user 10 10 1 Predefined macros: Defined by the TWiki system or by Plugins (for example, the SpreadSheetPlugin introduces a =%<nop>CALC{}%= macro) 11 11 … … 15 15 16 16 To use a macro type its name. For example, 17 * type =%<nop>T%= to get %T% (a preferences macro)18 * type =%<nop>TOPIC%= to get =%TOPIC%= (a predefined macro)19 * type =%<nop>CALC{ "$UPPER(Text)" }%= to get =TEXT= (a macro defined byPlugin)17 * type =%<nop>T%= to get %T% (a [[%SYSTEMWEB%.PreferenceSettings][preference settings]]) 18 * type =%<nop>TOPIC%= to get =%TOPIC%= (a predefined [[macro]]) 19 * type =%<nop>CALC{ "$UPPER(Text)" }%= to get =TEXT= (a [[macro]] defined by a Plugin) 20 20 21 21 __Note:__ … … 30 30 31 31 #SettingPrefs 32 #PreferencesVariables33 32 #PreferencesMacros 34 ---++ Preferences Macros33 ---++ Preferences 35 34 36 Unlike predefined macros, preferences macros can be defined by the user in various places. 35 _Preferences settings_ are simple macros that do _not_ accept parameters, and are 36 defined in topics. A lot of the macros you will encounter are of this type. 37 37 38 ---+++ Setting Preferences Macros 38 Preferences can be defined by the user in various places. 39 40 ---+++ Setting Preferences 39 41 You can set macros in all the following places: 40 1 local site level in [[%SYSTEMWEB%.DefaultPreferences][%SYSTEMWEB%.DefaultPreferences]]42 1 default level in [[%SYSTEMWEB%.DefaultPreferences][%SYSTEMWEB%.DefaultPreferences]] (*not* recommended) 41 43 1 plugin topics (see [[Plugins]]) 42 44 1 local site level in [[%LOCALSITEPREFS%][%LOCALSITEPREFS%]] 43 45 1 user level in individual user topics in %USERSWEB% web 44 1 web level in %WEBPREFSTOPIC% of each web 46 1 web level in %WEBPREFSTOPIC% of a parent web 47 1 web level in %WEBPREFSTOPIC% of the web 45 48 1 topic level in topics in webs 46 49 1 session macros (if sessions are enabled) … … 48 51 Settings at higher-numbered levels override settings of the same macro at lower numbered levels, unless the macro was included in the setting of FINALPREFERENCES at a lower-numbered level, in which case it is locked at the value it has at that level. 49 52 50 If you are setting a macro and using it in the same topic, note that TWiki reads all the macro settingsfrom the saved version of the topic before it displays anything. This means you can use a macro anywhere in the topic, even if you set it somewhere inconspicuous near the end. *But beware:* it also means that if you change the setting of a macro you are using in the same topic, ==Preview== will show the wrong thing, and you must ==Save== the topic to see it correctly.53 If you are setting a preference and using it in the same topic, note that TWiki reads all the [[%SYSTEMWEB%.PreferenceSettings][preference settings]] from the saved version of the topic before it displays anything. This means you can use a macro anywhere in the topic, even if you set it somewhere inconspicuous near the end. *But beware:* it also means that if you change the setting of a macro you are using in the same topic, ==Preview== will show the wrong thing, and you must ==Save== the topic to see it correctly. 51 54 52 55 The syntax for setting macros is the same anywhere in TWiki (on its own TWiki bullet line, including nested bullets): <br /> =[multiple of 3 spaces] * [space] Set [space] MACRONAME [space] = [space] value= … … 69 72 <blockquote> 70 73 *Example: Create a custom logo macro* <br /> 71 * To place a logo anywhere in a web by typing ==%<nop>MYLOGO%==, define the Macro on the web's WebPreferences topic, and upload a logo file, ex: =mylogo.gif=. You can upload by [[FileAttachment][attaching the file]] to WebPreferences, or, to avoid clutter, to any other topic in the same web, e.g. =LogoTopic=. Sample macrosetting in WebPreferences:74 * To place a logo anywhere in a web by typing ==%<nop>MYLOGO%==, define the [[%SYSTEMWEB%.PreferenceSettings][preference settings]] on the web's WebPreferences topic, and upload a logo file, ex: =mylogo.gif=. You can upload by [[FileAttachment][attaching the file]] to WebPreferences, or, to avoid clutter, to any other topic in the same web, e.g. =LogoTopic=. Sample preference setting in WebPreferences: 72 75 * ==<nop>Set MYLOGO = %<nop>PUBURL%/%<nop>WEB%/LogoTopic/mylogo.gif== 73 76 </blockquote> 74 77 75 You can also set preferences macros on a topic by clicking the link =Edit topic preference settings= under =More topic actions=. Preferences set in this manner are not visible in the topic text, but take effect nevertheless.78 You can also set [[%SYSTEMWEB%.PreferenceSettings][preference settings]] in a topic by clicking the link =Edit topic preference settings= under =More topic actions=. Preferences set in this manner are not visible in the topic text, but take effect nevertheless. 76 79 77 ---+++ Access Control Macros80 ---+++ Access Control Settings 78 81 79 These are special types of preference s macros to control access to content. AccessControl explains these security settings in detail.82 These are special types of preference settings to control access to content. AccessControl explains these security settings in detail. 80 83 81 ---+++ Local values for macros84 ---+++ Local values for preferences 82 85 Certain topics (a users home topic, web site and default preferences topics) have a problem; macros defined in those topics can have two meanings. For example, consider a user topic. A user may want to use a double-height edit box when they are editing their home topic - but *only* when editing their home topic. The rest of the time, they want to have a normal edit box. This separation is achieved using =Local= in place of =Set= in the macro definition. For example, if the user sets the following in their home topic: 83 86 <verbatim> … … 90 93 Use this powerful feature with great care! =%<nop>ALLVARIABLES%= can be used to get a listing of the values of all macros in their evaluation order, so you can see macro scope if you get confused. 91 94 92 ---+++ Frequently Used Preferences macros 95 #PreDef 96 ---++ Predefined Macros 93 97 94 The following macros are frequently used in topic content. They are defined in DefaultPreferences#Miscellaneous_Settings: 98 Most predefined macros return values that were either set in the configuration when TWiki was installed, or taken from server info (such as current username, or date and time). Some, like =%<nop>SEARCH%=, are powerful and general tools. 99 100 * %X% Predefined macros can be overridden by [[%SYSTEMWEB%.PreferenceSettings][preference settings]] (except TOPIC and WEB) 101 * %X% Plugins may extend the set of predefined macros (see individual Plugins topics for details) 102 * %T% *Take the time to thoroughly read through ALL preference macros.* If you actively configure your site, review macros periodically. They cover a wide range of functions, and it can be easy to miss the one perfect macro for something you have in mind. For example, see =%<nop>INCLUDINGTOPIC%=, =%<nop>INCLUDE%=, and the mighty =%<nop>SEARCH%=. 103 104 This version of TWiki - %WIKIVERSION% - predefines the following macros: 105 106 %SEARCH{ 107 "^Var[A-Z_0-9]+$" 108 casesensitive="on" 109 type="regex" 110 scope="topic" 111 format="$percntINCLUDE{$web.$topic}$percnt" 112 nonoise="on" 113 }% 114 115 ---+++ Shortcuts 116 117 The following macros are [[%SYSTEMWEB%.PreferenceSettings][preference settings]] and are frequently used in topic content. 95 118 * =%<nop>BR%= - line break 96 119 * =%<nop>BULLET%= - bullet sign … … 110 133 * =%<nop>Y%= - %Y% Done icon 111 134 112 !There are additional useful preferences macros defined in DefaultPreferences, in [[%LOCALSITEPREFS%]], and in WebPreferences of every web. 113 114 #PreDef 115 ---++ Predefined Macros 116 117 Most predefined macros return values that were either set in the configuration when TWiki was installed, or taken from server info (such as current username, or date and time). Some, like =%<nop>SEARCH%=, are powerful and general tools. 118 119 * %X% Predefined macros can be overridden by [[#PreferencesMacros][preferences macros]] (except TOPIC and WEB) 120 * %X% Plugins may extend the set of predefined macros (see individual Plugins topics for details) 121 * %T% *Take the time to thoroughly read through ALL preference macros.* If you actively configure your site, review macros periodically. They cover a wide range of functions, and it can be easy to miss the one perfect macro for something you have in mind. For example, see =%<nop>INCLUDINGTOPIC%=, =%<nop>INCLUDE%=, and the mighty =%<nop>SEARCH%=. 122 123 This version of TWiki - %WIKIVERSION% - predefines the following macros: 124 125 %SEARCH{ 126 "^Var[A-Z_0-9]+$" 127 casesensitive="on" 128 type="regex" 129 scope="topic" 130 format="$percntINCLUDE{$web.$topic}$percnt" 131 nonoise="on" 132 }% 135 See ShortcutMacros for a full list of predefined shortcuts. 133 136 134 137 %ENDSECTION{type="include"}%
Note: See TracChangeset
for help on using the changeset viewer.
