Difference: TWikiVariables (78 vs. 79)

Revision 7927 Mar 2005 - Main.TWikiContributor

Line: 1 to 1
 
META TOPICPARENT name="WebHome"
Line: 6 to 6
  Special text strings expand on the fly to display user data or system info
Changed:
<
<
TWikiVariables are text strings - %VARIABLE% - that expand into content whenever a page is rendered for viewing. VARIABLES are replaced by data, either user-entered or automatically generated by TWiki (like the date, or the current username). There are predefined variables, and Preference variables that you can configure. You can also define custom variables, with new names and values.
>
>
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:
  1. Preferences variables: Can be defined and changed by the user
  2. Predefined variables: Defined by the TWiki system or by Plugins (for example, the SpreadSheetPlugin introduces a %CALC{}% variable)

Using Variables

To use a variable type its name. For example,

  • type %T% to get TIP (a preferences variable)
  • type %TOPIC% to get TWikiVariables (a predefined variable)
  • type %CALC{ "$UPPER(Text)" }% to get TEXT (a variable defined by Plugin)

Note:

  • To leave a variable unexpanded, precede it with an exclamation point, e.g. type !%TOPIC% to get %TOPIC%
  • Variables are expanded relative to the topic they are used in, not the topic they are defined in
  • Type %ALLVARIABLES% to get a full listing of all variables defined for a particular topic
 
Deleted:
<
<
Notes:
  • To leave a variable unexpanded, precede it with an exclamation point, e.g. type !%TOPIC% to get %TOPIC%.
  • Variables are expanded relative to the topic they are used in, not the topic they are defined in.
 
Changed:
<
<

Predefined Variables

>
>

Preferences Variables

 
Changed:
<
<
Most predefined variables return values that were either set in the lib/twiki.cfg file, when TWiki was installed, or taken from server info (like current username, or date and time). Many of the variables let you format the appearance of the display results.
>
>
Unlike predefined variables, preferences variables can be defined by the user in various places.
 
Changed:
<
<
  • TIP Take the time to thoroughly read through ALL preference variables. If you actively configure your site, review variables periodically. They cover a wide range of functions, and it can be easy to miss the one perfect variable for something you have in mind. For example, see %INCLUDINGTOPIC%, %INCLUDE%, and the mighty %SEARCH%.
>
>

Setting Preferences Variables

You can set variables in all the following places:
  1. local site level in TWikiPreferences
  2. user level in individual user topics in Main web
  3. web level in WebPreferences of each web
  4. topic level in topics in webs
  5. plugin topics (see TWikiPlugins)
  6. session variables (if sessions are enabled)

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:
  • Set VARIABLENAME = value
    • Set VARIABLENAME = value
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.
Example:
	* Set VARIABLENAME = value starts here
	  and continues here
 
Changed:
<
<
This version of TWiki - TWiki-4.2.2, Wed, 06 Aug 2008, build 17396 - expands the following variables (enclosed in % percent signs):
>
>
Whatever you include in your Variable will be expanded on display, exactly as if it had been entered directly.
 
Changed:
<
<

Warning: Can't find topic TWiki.TWikiVariablesAtoM

Warning: Can't find topic TWiki.TWikiVariablesNtoZ

>
>
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
 
Changed:
<
<
Note: Above text is included from TWikiVariablesAtoM? and TWikiVariablesNtoZ?
>
>
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.
 
Added:
>
>

Access Control Variables

 
Changed:
<
<

Preferences Variables

>
>
These are special types of preferences variables to control access to content. TWikiAccessControl explains these security settings in detail.
 
Changed:
<
<
Additional variables are defined in the preferences topics:

Variable: Level: What: Expands to:
%ALLOWTOPICCHANGE% (any topic) List of users and groups who are allowed to change the current topic. (More in TWikiAccessControl) TWikiAdminGroup  
%ALLOWTOPICRENAME% (any topic) List of users and groups who are allowed to rename the current topic. (More in TWikiAccessControl) TWikiAdminGroup?  
%ALLOWWEBCHANGE% WL List of users and groups who are allowed to change topics in the TWiki web. (More in TWikiAccessControl) TWikiAdminGroup  
%ALLOWWEBRENAME% WL List of users and groups who are allowed to rename topics in the TWiki web. (More in TWikiAccessControl) TWikiAdminGroup  
%ATTACHLINKBOX% SL , UL Default state of the link check box in the attach file page. Check box is initially checked if value is set to CHECKED , unchecked if empty. If checked, a link is created to the attached file at the end of the topic. Value is:  
%DENYTOPICCHANGE% (any topic) List of users and groups who are not allowed to change the current topic. (More in TWikiAccessControl) %DENYTOPICCHANGE%  
%DENYTOPICRENAME% (any topic) List of users and groups who are not allowed to rename the current topic. (More in TWikiAccessControl) %DENYTOPICRENAME%  
%DENYWEBCHANGE% WL List of users and groups who are not allowed to change topics in the TWiki web. (More in TWikiAccessControl) %DENYWEBCHANGE%  
%DENYWEBRENAME% WL List of users and groups who are not allowed to rename topics in the TWiki web. (More in TWikiAccessControl) %DENYWEBRENAME%  
%DONTNOTIFYCHECKBOX% SL , UL Default state of the "Minor Changes, Don't Notify" (DontNotify) check box in preview. Check box is initially checked if Set DONTNOTIFYCHECKBOX = checked="checked", or unchecked if empty. Value is:  
%EDITBOXHEIGHT% SL , UL Vertical size of edit box, is 20 20  
%EDITBOXWIDTH% SL , UL Horizontal size of edit box, is 70 70  
%EDITBOXSTYLE% SL , UL Style of text edit box. Set to width: 99% for full window width (default; overwrites the EDITBOXWIDTH setting), or width: auto to disable. Value is: width:99% width:99%  
%FINALPREFERENCES% SL , WL List of preferences that are not allowed to be overridden by next level preferences NOSEARCHALL, ATTACHFILESIZELIMIT, WIKIWEBMASTER, WEBCOPYRIGHT, WEBTOPICLIST, DENYWEBVIEW, ALLOWWEBVIEW, DENYWEBCHANGE, ALLOWWEBCHANGE, ALLOWWEBRENAME, DENYWEBRENAME  
%HTTP_EQUIV_ON_EDIT% SL , UL http-equiv meta tags for edit script.  
%HTTP_EQUIV_ON_PREVIEW% SL , UL http-equiv meta tags for preview script.  
%HTTP_EQUIV_ON_VIEW% SL http-equiv meta tags for view, rdiff, attach, search* scripts.  
%NEWTOPICBGCOLOR% SL , UL Background color of non existing topic. ( UL needs authentication for topic views ) %NEWTOPICBGCOLOR%  
%NEWTOPICFONTCOLOR% SL , UL Font color of non existing topic. ( UL needs authentication for topic views ) %NEWTOPICFONTCOLOR%  
%NOSEARCHALL% WL Exclude web from a web="all" search (set variable to on for hidden webs)  
%RELEASEEDITLOCKCHECKBOX% SL , UL Default state of the "Release edit lock" (UnlockTopic? ) check box in preview. Checkbox is initially checked if Set RELEASEEDITLOCKCHECKBOX = checked="checked", or unchecked if empty. If checked, make sure to click on Edit to do more changes; do not go back in your browser to the edit page, or you risk that someone else will edit the topic at the same time! Value is: %RELEASEEDITLOCKCHECKBOX% %RELEASEEDITLOCKCHECKBOX%  
%WEBBGCOLOR% WL Background color of web #FFD8AA  
%WEBCOPYRIGHT% SL , WL Copyright notice (bottom right corner of topics) This site is powered by the TWiki collaboration platformCopyright � by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback
Note: Please contribute updates to this topic on TWiki.org at TWiki:TWiki.TWikiVariables  
%WEBTOPICLIST% WL Common links of web (second line of topics) Welcome  |  Register  |  Changes  |  Topics  |  Index  |  Search  |  Go  
%WIKIWEBLIST% SL List of TWiki webs (in upper right corner of topics) Main  |  TWiki  |  Sandbox?  
%WIKIWEBMASTER% SL Webmaster email address (sender of email notifications) , is twiki@ufba.br twiki@ufba.br  
>
>

Local values for variables

Certain topics (a users home topic, web site and default preferences topics) have a problem; variables 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 variable definition. For example, if the user sets the following in their home topic:
   * Set EDITBOXHEIGHT = 10
   * Local EDITBOXHEIGHT = 20
Then 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.

Frequently Used Preferences Variables

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% - HELP Help icon
  • %I% - IDEA! Idea icon
  • %M% - MOVED TO... Moved to icon
  • %N% - NEW New icon
  • %P% - REFACTOR Refactor icon
  • %Q% - QUESTION? Question icon
  • %S% - PICK Pick icon
  • %T% - TIP Tip icon
  • %U% - UPDATED Updated icon
  • %X% - ALERT! Alert icon
  • %Y% - DONE Done icon
 
Changed:
<
<
Note: There are some more useful variables defined in the TWikiPreferences like %BR% for line break, colors like %RED% for colored text and small icons like %H% for a HELP Help icon.
>
>
There are additional useful preferences variables defined in TWikiPreferences, in Main.TWikiPreferences, and in WebPreferences of every web.
 
Changed:
<
<

Setting Preferences

>
>

Predefined Variables

 
Changed:
<
<
  • The syntax for Preferences 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] = [value]
    Examples:
  • Set VARIABLENAME = value
    • Set VARIABLENAME = value
>
>
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.
 
Changed:
<
<

Creating Custom Variables

>
>
  • ALERT! Predefined variables can be overridden by preferences variables
  • ALERT! Plugins may extend the set of predefined variables (see individual Plugins topics for details)
  • TIP Take the time to thoroughly read through ALL preference variables. If you actively configure your site, review variables periodically. They cover a wide range of functions, and it can be easy to miss the one perfect variable for something you have in mind. For example, see %INCLUDINGTOPIC%, %INCLUDE%, and the mighty %SEARCH%.
 
Changed:
<
<
  • You can add your own Preference Variables for us across an entire site or a single web, using the standard Preferences syntax. Whatever you include in your Variable will be expanded on display, exactly as if it had been entered directly. You can place formatted text, page links, image paths.
>
>
This version of TWiki - TWiki-4.2.2, Wed, 06 Aug 2008, build 17396 - predefines the following variables:
 
Changed:
<
<
Example: Create a custom logo variable the TWiki web
  • To place a logo anywhere in a web by typing %MYLOGO%, define the Variable on the web's WebPreferences page, 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, ex: LogoTopic:
    • Set MYLOGO = %PUBURL%/TWiki/LogoTopic/mylogo.gif
>
>

Warning: Can't find topic TWiki.TWikiVariablesAtoM

Warning: Can't find topic TWiki.TWikiVariablesNtoZ

 
Deleted:
<
<
-- TWiki:Main.PeterThoeny - 14 Aug 2004
-- TWiki:Main.MikeMannix - 12 May 2002
 
Changed:
<
<
Crawford split up this topic into included TWikiVariablesAtoM? and TWikiVariablesNtoZ? .

-- PeterThoeny - 26 Jul 2004

>
>
Related Topics: UserDocumentationCategory
 
 
This site is powered by the TWiki collaboration platformCopyright � by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback
Note: Please contribute updates to this topic on TWiki.org at TWiki:TWiki.TWikiVariables