%VARIABLE% or %VARIABLE{ parameter="value" }% - that expand into content whenever a topic is rendered for viewing. There are two types of variables: %CALC{}% variable)
%T% to get %TOPIC% to get TWikiVariables (a predefined variable)
%CALC{ "$UPPER(Text)" }% to get TEXT (a variable defined by Plugin)
!%TOPIC% to get %TOPIC%
%ALLVARIABLES% to get a full listing of all variables defined for a particular topic
%MYVAR%, %MyVar%, %My2ndVar%, and %My_Var% are all valid variable names. Variables are case sensitive. %MyVAR% and %MYVAR% are not the same variable.
By convention all settings, predefined variables and variables used by plugins are always UPPER-CASE.
[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 variableYou can also set preferences variables on a topic by clicking the link
- 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
Edit topic preference settings under More topic actions. Preferences set in this manner are not visible in the topic text, but take effect nevertheless.
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.
%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% - %SEARCH%, are powerful and general tools.
%INCLUDINGTOPIC%, %INCLUDE%, and the mighty %SEARCH%.
%ACTIVATEDPLUGINS%
%ALLVARIABLES%
%ATTACHURL%
http://www.massbug.org.au/twiki/pub/TWiki/VarATTACHURL
%ATTACHURL%/image.gif
%ATTACHURLPATH%
/twiki/pub/TWiki/VarATTACHURLPATH
configure. This is used in certain password encodings, and in login templates as part of the login prompt.
%AUTHREALM%
%TOPIC% if there is no INCLUDE
%BASETOPIC%
%WEB% in case there is no include.
%BASEWEB%
%DATE%
09 Jan 2009
%DISPLAYTIME%
09 Jan 2009 - 00:02
%GMTIME%
%DISPLAYTIME{"format"}%
%DISPLAYTIME{"$hou:$min"}% expands to 00:02
"\n") and linefeed ("\r")
"<", ">", "&", single quote (') and double quote (")
"%", "[", "]", "@", "_", "*", "=" and "|"
%ENCODE{"string"}%
| Parameter: | Description: | Default: |
|---|---|---|
"string" | String to encode | required (can be empty) |
type="entity" | Encode special characters into HTML entities, like a double quote into " | URL encoding |
type="url" | Encode special characters for URL parameter use, like a double quote into %22 | (this is the default) |
%ENCODE{"spaced name"}% expands to spaced%20name
<input type="text" name="address" value="%ENCODE{ "any text" type="entity" }%" />
%ENDSECTION{"name"}%
%ENDSECTION{type="include"}%
| Parameter: | Description: |
|---|---|
"name" | Name of the section. |
type="..." | Type of the section being terminated; supported types "section", "include", "templateonly". |
STARTSECTION is named, the corresponding ENDSECTION must also be named with the same name. If the STARTSECTION specifies a type, then the corresponding ENDSECTION must also specify the same type. If the section is unnamed, ENDSECTION will match with the nearest unnamed %STARTSECTION% of the same type above it.
%FAILEDPLUGINS%
%FORMFIELD{"fieldname"}%
| Parameter: | Description: | Default: |
|---|---|---|
"fieldname" | The name of a TWiki form field | required |
topic="..." | Topic where form data is located. May be of the form Web.TopicName | Current topic |
format="..." | Format string. $value expands to the field value, and $title expands to the field title | "$value" |
default="..." | Text shown when no value is defined for the field | "" |
alttext="..." | Text shown when field is not found in the form | "" |
%FORMFIELD{"ProjectName" topic="Projects.SushiProject" default="(not set)" alttext="ProjectName field found"}%
%GMTIME%
09 Jan 2009 - 00:02
%GMTIME{"format"}%
| Variable: | Unit: | Example |
|---|---|---|
$seconds | seconds | 59 |
$minutes | minutes | 59 |
$hours | hours | 23 |
$day | day of month | 31 |
$wday | day of the Week (Sun, Mon, Tue, Wed, Thu, Fri, Sat) | Thu |
$dow | day of the week (Sun = 0) | 2 |
$week | number of week in year (ISO 8601) | 34 |
$month | month in ISO format | Dec |
$mo | 2 digit month | 12 |
$year | 4 digit year | 1999 |
$ye | 2 digit year | 99 |
$tz | either "GMT" (if set to gmtime), or "Local" (if set to servertime) | GMT |
$iso | ISO format timestamp | 2009-01-09T00:02:47Z |
$rcs | RCS format timestamp | 2009/01/09 00:02:47 |
$http | E-mail & http format timestamp | Fri, 09 Jan 2009 00:02:47 GMT |
$epoch | Number of seconds since 00:00 on 1st January, 1970 | 1231459367 |
%GMTIME{"$day $month, $year - $hour:$min:$sec"}% expands to 09 Jan, 2009 - 00:02:47
%HOMETOPIC%
WebHome, renders as WebHome
%HTTP%
%HTTP{"Header-name"}%
%HTTP% | |
%HTTP{"Accept-language"}% | en-us,en;q=0.5 |
%HTTP{"User-Agent"}% | CCBot/1.0 (+http://www.commoncrawl.org/bot.html) |
%HTTP_HOST%
www.massbug.org.au
%HTTP% but operates on the HTTPS environment variables present when the SSL protocol is in effect. Can be used to determine whether SSL is turned on.
%HTTPS%
%HTTPS{"Header-name"}%
%ICON{"name"}%
%ICON{"flag-gray"}% returns %ICON{"pdf"}% returns %ICON{"smile.pdf"}% returns %ICON{"/dont/you/dare/smile.pdf"}% returns %ICON{"http://twiki.org/doc/xhtml.xsl"}% returns arrowbright, bubble, choice-yes, hand
bmp, doc, gif, hlp, html, mp3, pdf, ppt, txt, xls, xml, zip
%ICON{"name"}% generates the full HTML img tag. Specify image name or full filename (see ICON for details on filenames.)
%ICONURL{"name"}%
%ICONURL{"arrowbright"}% returns http://www.massbug.org.au/twiki/pub/TWiki/TWikiDocGraphics/arrowbright.gif
%ICONURL{"novel.pdf"}% returns http://www.massbug.org.au/twiki/pub/TWiki/TWikiDocGraphics/pdf.gif
%ICONURL{"/queen/boheme.mp3"}% returns http://www.massbug.org.au/twiki/pub/TWiki/TWikiDocGraphics/mp3.gif
%ICONURLPATH{"name"}%
%ICONURLPATH{"locktopic"}% returns /twiki/pub/TWiki/TWikiDocGraphics/locktopic.gif
%ICONURLPATH{"eggysmell.xml"}% returns /twiki/pub/TWiki/TWikiDocGraphics/xml.gif
%ICONURLPATH{"/doc/xhtml.xsl"}% returns /twiki/pub/TWiki/TWikiDocGraphics/xsl.gif
%IF{"CONDITION" then="THEN" else="ELSE"}% shows "THEN" if "CONDITION" evaluates to TRUE, otherwise "ELSE" will be shown
%IF{"defined FUNFACTOR" then="FUNFACTOR is defined" else=" is not defined"}% renders as ==
%INCLUDE{"page" ...}%
| Parameter: | Description: | Default: |
|---|---|---|
"SomeTopic" | The name of a topic located in the current web, i.e. %INCLUDE{"WebNotify"}% | |
"Web.Topic" | A topic in another web, i.e. %INCLUDE{"TWiki.SiteMap"}% | |
"http://..." | A full qualified URL, i.e. %INCLUDE{"http://twiki.org:80/index.html"}%. Supported content types are text/html and text/plain. | |
pattern="..." | A RegularExpression pattern to include a subset of a topic or page | none |
rev="2" | Include a previous topic revision; N/A for URLs | top revision |
raw="on" | When a page is included, normally TWiki will process it, doing the following: 1) Alter relative links to point back to originating host, 2) Remove some basic HTML tags (html, head, body, script) and finally 3) Remove newlines from tags spanning multiple lines. If you prefer to include exactly what is in the source of the originating page set this to on. | disabled |
warn="off" | Warn if topic include fails: Fail silently (if off); output default warning (if set to on); else, output specific text (use $topic for topic name) | %INCLUDEWARNING% preferences setting |
section="name" | Includes only the specified named section, as defined in the included topic by the STARTSECTION and ENDSECTION variables | |
PARONE="val 1" | Any other parameter will be defined as a variable within the scope of the included topic. The example parameters on the left will result in %PARONE% and %PARTWO% being defined within the included topic. |
raw parameter)
%TOPIC% in case there is no include
%INCLUDINGTOPIC%
%WEB% if there is no INCLUDE.
%INCLUDINGWEB%
LANGUAGE preference is set, it's used as user's language instead of any language detected from the browser.
LANGUAGE at a non per-user way, so each user can choose his/her preferred language.
PO files) to TWiki. Those are the languages in which TWiki's user interface is available.
%LANGUAGES{...}%
| Parameter: | Description: | Default: |
|---|---|---|
format | format for each item. See below for variables available in the format string. | " * $langname" |
separator | separator between items. | "\n" (newline) |
marker="selected" | Text for $marker if the item matches selection | "selected" |
selection="%LANGUAGE%" | Current language to be selected in list | (none) |
format variables: | Variable | Meaning |
|---|---|
$langname | language's name, as informed by the translators |
$langtag | language's tag. Ex: en, pt-br, etc. |
<select>%LANGUAGES{format="<option $marker value='$langtag'>$langname</option>" selection="%LANGUAGE%"}%</select> creates an option list of the available languages with the current language selected
%LOCALSITEPREFS%
Main.TWikiPreferences, renders as TWikiPreferences
%LOGIN%
%LOGOUT%
%MAINWEB%
Main
%MAKETEXT{"string" args="..."}
| Parameter | Description | Default |
|---|---|---|
"text" or string="text" | The text to be displayed. | none |
args="param1, param2" | a comma-separated list of arguments to be interpolated in the string, replacing the [_N] placeholders in it. | none |
%MAKETEXT{string="Notes:"}% %MAKETEXT{"If you have any questions, please contact [_1]." args="%WIKIWEBMASTER%"}% %MAKETEXT{"Did you want to [[[_1]][reset [_2]'s password]]?" args="%TWIKIWEB%.ResetPassword,%WIKIUSERNAME%"}% string to the current user's language only if it has such string in its translation table for that language.
&) followed by one letter (one of a...z, A...Z) (say, X) in the translatable string will be translated to <span class='twikiAccessKey'>X</span>. This is used to implement access keys. If you want to write an actual amperstand that stays just before a letter, write two consecutive amperstands (&&): they will be transformed in just one.
_) are reserved. You cannot use translatable phrases starting with an underscore.
%VARIABLES% inside the translatable strings (since they will get expanded before the %MAKETEXT{...}% itself is handled).
formfield item is the most likely to be useful to casual users.
%META{ "item" ...}%
| Item | Options | Description |
|---|---|---|
"formfield" | name="..." - name of the field. The field value can be shortened as described in FormattedSearch for $formfield | Show a single form field |
"form" | none | Generates the table showing the form fields. See Form Templates |
"attachments" | all="on" to show hidden attachments | Generates the table showing the attachments |
"moved" | none | Details of any topic moves |
"parent" | dontrecurse="on": By default recurses up tree, this has some cost. nowebhome="on": Suppress WebHome. prefix="...": Prefix that goes before parents, but only if there are parents, default "". suffix="...": Suffix, only appears if there are parents, default "". separator="...": Separator between parents, default is " > ". | Generates the parent link |
%METASEARCH{...}%
| Parameter: | Description: | Default: |
|---|---|---|
type="topicmoved" | What sort of search is required? "topicmoved" if search for a topic that may have been moved "parent" if searching for topics that have a specific parent i.e. its children "field" if searching for topics that have a particular form field value (use the name and value parameters to specify which field to search) | required |
web="%WEB%" | Wiki web to search: A web, a list of webs separated by whitespace, or all webs. | current web |
topic="%TOPIC%" | The topic the search relates to, for topicmoved and parent searches | current topic |
name | form field to search, for field type searches. May be a regular expression (see SEARCH). | |
value | form field value, for field type searches. May be a regular expression (see SEARCH). | |
title="Title" | Text that is prefixed to any search results | empty |
default="none" | Default text shown if no search hit | empty |
%METASEARCH{type="topicmoved" web="%WEB%" topic="%TOPIC%" title="This topic used to exist and was moved to: "}%
%METASEARCH{type="parent" web="%WEB%" topic="%TOPIC%" title="Children: "}%
%METASEARCH{type="field" name="Country" value="China"}%
%NOP% %NOP{...}% deprecated %STARTSECTION{type="templateonly"}% .. %ENDSECTION{type="templateonly"}% instead (see TWikiTemplates for more details).
%NOTIFYTOPIC%
WebNotify, renders as WebNotify
%PLUGINDESCRIPTIONS%
"$SUM( $ABOVE() )" to tables located in TWiki topics.ExternalSite:Page text to external sites based on aliases defined in a rules topic :-) for
or :cool: for :cool:%PLUGINVERSION{"name"}% to get the version of a specific plugin
%PLUGINVERSION{"InterwikiPlugin"}% expands to $Rev: 8329$
%PLUGINVERSION% to get the version of the API
1.1
%PUBURL%
http://www.massbug.org.au/twiki/pub
%PUBURL%/%WEB%/OtherTopic/image.gif
%PUBURLPATH%
/twiki/pub
%URLPARAM{}%.
%QUERYSTRING%
%REMOTE_ADDR%
38.103.63.58
%REMOTE_PORT%
59488
%REMOTE_USER%
%REVINFO%
r0 - 27 Mar 2005 - 13:14:15 - TWikiContributor
%REVINFO{"format"}%
| Parameter: | Description: | Default: |
|---|---|---|
"format" | Format of revision information, see supported variables below | "r1.$rev - $date - $wikiusername" |
web="..." | Name of web | Current web |
topic="..." | Topic name | Current topic |
rev="1.5" | Specific revison number | Latest revision |
| Variable: | Unit: | Example |
|---|---|---|
$web | Name of web | Current web |
$topic | Topic name | Current topic |
$rev | Revison number. Prefix r1. to get the usual r1.5 format | 5 |
$date | Revision date | 11 Jul 2004 |
$time | Revision time | 23:24:25 |
$username | Login username of revision | jsmith |
$wikiname | WikiName of revision | JohnSmith |
$wikiusername | WikiName with Main web prefix | Main.JohnSmith |
%REVINFO{"$date - $wikiusername" rev="1.1"}% returns revision info of first revision
viewauth.cgi)
%SCRIPTNAME%
view
.pl or .cgi
%SCRIPTSUFFIX%
%SCRIPTURL%
http://www.massbug.org.au/cgi-bin/twiki/bin
%SCRIPTURL{"script"}%
http://www.massbug.org.au/cgi-bin/twiki/bin/script
%SCRIPTURL{"viewauth"}%/%WEB%/%TOPIC% which expands to http://www.massbug.org.au/cgi-bin/twiki/bin/viewauth/TWiki/TWikiVariables
%SCRIPTURLPATH{"script"}% instead, as it works with URL rewriting much better
%SCRIPTURL%, but doesn't include the protocol and host part of the URL
%SCRIPTURLPATH%
/cgi-bin/twiki/bin
%SCRIPTURL{"script"}%, but doesn't include the protocol and host part of the URL
%SCRIPTURLPATH{"script"}%
/cgi-bin/twiki/bin/script
%SEARCH{"text" ...}%
| Parameter: | Description: | Default: |
|---|---|---|
"text" | Search term. Is a keyword search, literal search or regular expression search, depending on the type parameter. SearchHelp has more | required |
search="text" | (Alternative to above) | N/A |
web="Name" web="Main, Know" web="all" | Comma-separated list of webs to search. You can specifically exclude webs from an all search using a minus sign - for example, web="all,-Secretweb". The special word all means all webs that do not have the NOSEARCHALL variable set to on in their WebPreferences. Note that TWikiAccessControls are respected when searching webs; it is much better to use them than NOSEARCHALL. | Current web |
topic="WebPreferences" topic="*Bug" | Limit search to topics: A topic, a topic with asterisk wildcards, or a list of topics separated by comma. Note this is a list of topic names and must not include web names. | All topics in a web |
excludetopic="Web*" excludetopic="WebHome, WebChanges" | Exclude topics from search: A topic, a topic with asterisk wildcards, or a list of topics separated by comma. Note this is a list of topic names and must not include web names. | None |
type="keyword" type="literal" type="regex" | Do a keyword search like soap "web service" -shampoo; a literal search like web service; or RegularExpression search like soap;web service;!shampoo | %SEARCHVAR- DEFAULTTYPE% preferences setting (literal) |
scope="topic" scope="text" scope="all" | Search topic name (title); the text (body) of topic; or all (both) | "text" |
order="topic" order="created" order="modified" order="editby" order= | Sort the results of search by the topic names, topic creation time, last modified time, last editor, or named field of TWikiForms. The sorting is done web by web; if you want to sort across webs, create a formatted table and sort it with TablePlugin's initsort. Note that dates are sorted most recent date last (i.e at the bottom of the table). | Sort by topic name |
limit="all" limit="16" | Limit the number of results returned. This is done after sorting if order is specified | All results |
date="..." | limits the results to those pages with latest edit time in the given TimeInterval. | All results |
reverse="on" | Reverse the direction of the search | Ascending search |
casesensitive="on" | Case sensitive search | Ignore case |
bookview="on" | BookView search, e.g. show complete topic text | Show topic summary |
nonoise="on" | Shorthand for nosummary="on" nosearch="on" nototal="on" zeroresults="off" noheader="on" noempty="on" | Off |
nosummary="on" | Show topic title only | Show topic summary |
nosearch="on" | Suppress search string | Show search string |
noheader="on" | Suppress search header Topics: Changed: By: | Show search header, unless seach is inline and a format is specified (Cairo compatibility) |
nototal="on" | Do not show number of topics found | Show number |
zeroresults="off" | Suppress all output if there are no hits | zeroresults="on", displays: "Number of topics: 0" |
noempty="on" | Suppress results for webs that have no hits. | Show webs with no hits |
header="..." format="..." | Custom format results: see FormattedSearch for usage, variables & examples | Results in table |
expandvariables="on" | Expand variables before applying a FormattedSearch on a search hit. Useful to show the expanded text, e.g. to show the result of a SpreadSheetPlugin %CALC{}% instead of the formula | Raw text |
multiple="on" | Multiple hits per topic. Each hit can be formatted. The last token is used in case of a regular expression ";" and search | Only one hit per topic |
nofinalnewline="on" | If on, the search variable does not end in a line by itself. Any text continuing immediately after the search variable on the same line will be rendered as part of the table generated by the search, if appropriate. | off |
recurse="on" | Recurse into subwebs, if subwebs are enabled. | off |
separator=", " | Line separator between hits | Newline "$n" |
%SEARCH{"wiki" web="Main" scope="topic"}%
%SEARCH{"FAQ" scope="topic" nosearch="on" nototal="on" header="| *Topic: * | *Summary: * |" format="| $topic | $summary |"% (displays results in a table with header - details)
%TABLE{}% variable just before the %SEARCH{}% to alter the output of a search. Example: %TABLE{ tablewidth="90%" }%
%SERVERTIME%
08 Jan 2009 - 19:02
%GMTIME%
%SERVERTIME{"format"}%
%SERVERTIME{"$hou:$min"}% expands to 19:02
%SESSIONID%
%SESSIONVAR%
%SESSION_VARIABLE{"name"}%
%SESSION_VARIABLE{"name" set="value"}%
%SESSION_VARIABLE{"name" clear=""}%
AUTHUSER session variable, and is read-only
%SPACEDTOPIC%
Var%20*SPACEDTOPIC
%ENCODE{%SPACEOUT{"%TOPIC%" separator=" *"}%}%
%SPACEOUT{ "%TOPIC%" }%
TWiki Variables
| Parameter: | Description: | Default: |
|---|---|---|
separator | The separator to put between words e.g. %SPACEOUT{"DogsCatsBudgies" separator=", "}% -> Dogs, Cats, Budgies | ' ' |
[[WebHome][%SPACEOUT{"WebHome"}%]] expands to Web Home
%STOPINCLUDE% variable. A normal view of the topic shows everything exept the %STARTINCLUDE% variable itself.
%STARTSECTION{type="include"}% instead
%STARTINCLUDE%
%S