Operators |
and |
True if both sides are true |
or |
True if one or other side is true |
not |
negate the following expression |
=, != |
String comparison |
<, >, <=, >= |
Number comparison (there is no explicit numeric =) |
context |
True if the current context is set (see below) |
defined |
True if a preference variable or url parameter of this name is defined. |
$ |
expands a URL parameter or [[Main/TWikiVariables]]. Plugin handlers are not called. Built-in variables and user-defined preferences are supported. You can pass a limited subset of parameters to TWiki variables by enclosing the variable name in single quotes; for example, $ 'VARIABLE{value}' . The 'VARIABLE{value}' string may not contain quotes (' or "). |
examples:
TWiki variable defined or not
%IF{"defined WIKINAME" then="WIKINAME is defined" else="WIKINAME is not defined"}%
You are %IF{ "$ WIKINAME='TWikiGuest' and not defined OPEN_DAY" then="not" }% allowed to
%IF{ "context view" then="view" else="edit"}% this TWiki today.
URL parameter
%IF{ "defined search" then="Search: %URLPARAM{search}%" else="No search passed in"}%
Configuration item set or not
%IF{ "{AntiSpam}{HideUserDetails}" then="User details are hidden" }%
url param t is %IF{ "0 < $ t and $ t < 1000" then="in" else="out of"}% range.
Text comparison
%IF{ "$'URLPARAM{scope}'='text'" then="Plain text search" }%
**Configuration items** are defined in [configure](http://www.dementia.org/twiki/configure). You cannot see the value of a configuration item, you can only see if the item is set or not.
**Context identifiers** are used in TWiki to label various stages of the rendering process. They are especially useful for [[skin|Main/TWikiSkins]] authors to find out where they are in the rendering process. The following context identifiers are available:
id |
context |
absolute_urls |
Set if absolute URLs are required |
authenticated |
a user is authenticated |
body_text |
when the body text is being processed in a view (useful in plugin handlers) |
can_login |
current environment supports login |
changes |
in changes script (see [[Main/TWikiScripts]]) |
command_line |
the running script was run from the command line, and not from CGI |
diff |
in rdiff script (see [[Main/TWikiScripts]]) |
edit |
in edit script (see [[Main/TWikiScripts]]) |
footer_text |
when the footer text is being processed in a view (useful in plugin handlers) |
header_text |
when the header text is being processed in a view (useful in plugin handlers) |
i18n_enabled |
when user interface I18N support is enabled (i.e., user can choose the language for UI) |
inactive |
if active links such as 'edit' and 'attach' should be disabled |
mirror |
if this is a mirror |
new_topic |
if the topic doesn't already exist |
oops |
in oops script (see [[Main/TWikiScripts]]) |
preview |
in preview script (see [[Main/TWikiScripts]]) |
rss |
if this is an RSS skin rendering |
save |
in save script (see [[Main/TWikiScripts]]) |
search |
in search script (see [[Main/TWikiScripts]]) |
view |
in view script (see [[Main/TWikiScripts]]) |
rest |
in rest script (see [[Main/TWikiScripts]]) |
In addition there is a context identifier for each enabled plugin; for example, if `GallousBreeksPlugin` is installed **and enabled**, then the context ID `GallousBreeksPluginEnabled` will be set. Other extensions may set additional context identifiers.
The `%IF%` statement is deliberately kept simple. In particular, note that there is no way to conditionally execute a Set statement. If you need more sophisticated control over formatting, then consider using the [[SpreadSheetPlugin]].