Special text strings expand on the fly to display user data or system info
TWikiVariables are text strings - %VARIABLE%
or %VARIABLE{ parameter="value" }%
- that expand into content whenever a topic is rendered for viewing. There are two types of variables:
%CALC{}%
variable)
To use a variable type its name. For example,
%T%
to get %TOPIC%
to get TWikiVariables
(a predefined variable)
%CALC{ "$UPPER(Text)" }%
to get TEXT
(a variable defined by Plugin)
Note:
!%TOPIC%
to get %TOPIC%
%ALLVARIABLES%
to get a full listing of all variables defined for a particular topic
Unlike predefined variables, preferences variables can be defined by the user in various places.
Settings at higher-numbered levels override settings of the same variable at lower numbered levels, unless the variable 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.
The syntax for setting Variables is the same anywhere in TWiki (on its own TWiki bullet line, including nested bullets):
[multiple of 3 spaces] * [space] Set [space] VARIABLENAME [space] = [space] value
Examples:Spaces between the = sign and the value will be ignored. You can split a value over several lines by indenting following lines with spaces - as long as you don't try to use * as the first character on the following line.
Set VARIABLENAME = value
Set VARIABLENAME = value
Example:* Set VARIABLENAME = value starts here and continues here
Whatever you include in your Variable will be expanded on display, exactly as if it had been entered directly.
Example: Create a custom logo variable
- To place a logo anywhere in a web by typing
%MYLOGO%
, define the Variable on the web's WebPreferences topic, and upload a logo file, ex:mylogo.gif
. You can upload by attaching the file to WebPreferences, or, to avoid clutter, to any other topic in the same web, e.g.LogoTopic
. Sample variable setting in WebPreferences:
Set MYLOGO = %PUBURL%/%WEB%/LogoTopic/mylogo.gif
You can also set preferences variables 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.
These are special types of preferences variables to control access to content. TWikiAccessControl explains these security settings in detail.
Local
in place of Set
in the variable definition. For example, if the user sets the following in their home topic:
* Set EDITBOXHEIGHT = 10 * Local EDITBOXHEIGHT = 20Then when they are editing any other topic, they will get a 10 high edit box. However when they are editing their home topic, they will get a 20 high edit box.
Local
can be used wherever a preference needs to take a different value depending on where the current operation is being performed.
Use this powerful feature with great care! %ALLVARIABLES%
can be used to get a listing of the values of all variables in their evaluation order, so you can see variable scope if you get confused.
The following preferences variables are frequently used. They are defined in TWikiPreferences#Miscellaneous_Settings:
%BR%
- line break
%BULLET%
- bullet sign
%BB%
- line break and bullet combined
%BB2%
- indented line break and bullet
%RED% text %ENDCOLOR%
- colored text (also %YELLOW%
, %ORANGE%
, %PINK%
, %PURPLE%
, %TEAL%
, %NAVY%
, %BLUE%
, %AQUA%
, %LIME%
, %GREEN%
, %OLIVE%
, %MAROON%
, %BROWN%
, %BLACK%
, %GRAY%
, %SILVER%
, %WHITE%
)
%H%
- %I%
- %M%
- %N%
- %P%
- %Q%
- %S%
- %T%
- %U%
- %X%
- %Y%
- There are additional useful preferences variables defined in TWikiPreferences, in Main.TWikiPreferences, and in WebPreferences of every web.
Most predefined variables 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 %SEARCH%
, are powerful and general tools.
%INCLUDINGTOPIC%
, %INCLUDE%
, and the mighty %SEARCH%
.
This version of TWiki - TWiki-4.2.0, Tue, 22 Jan 2008, build 16278 - predefines the following variables:
Warning: Can't find topic TWiki.TWikiVariablesAtoM
Warning: Can't find topic TWiki.TWikiVariablesNtoZ
Related Topics: UserDocumentationCategory