Difference: IfStatements (7 vs. 8)

Revision 82009-06-05 - TWikiContributor

Line: 1 to 1
 

IF Statements

The %IF% construct gives TWiki the power to include content in topics based on the value of simple expressions.

Line: 9 to 9
  Note that because of the way TWiki evaluates, then whatever is in the THEN and ELSE parameters will already have been expanded by the time the condition is actually evaluated. The standard FormatTokens can be used in the THEN and ELSE parameters when you need to delay evaluation of (for example) a TWiki variable.
Changed:
<
<
The basic syntax of a condition is the same as the syntax used for queries, with the addition of the following special operators:
>
>
The basic syntax of a condition is the same as the syntax used for queries, with operators =, !=, ~, <, >, <=, >=, NOT, AND, OR, (), and functions lc(), uc(), d2n(). In addition, the following special operators are supported:
 
Changed:
<
<
context True if the current context is set (see below)
allows 'X' allows 'Y' is true if web/topic 'X' exists and allows access mode 'Y' for the current user. Web access rights are only checked if there is no topic called 'X'.
istopic istopic 'X' is true if topic 'X' exists
isweb isweb 'X' is true if web 'X' exists
ingroup 'X' ingroup 'Y' is true if user 'X' is in group 'Y'. 'X' can be a login name or a wikiname.
defined True if a preference variable or url parameter of this name is defined.
$ expands a URL parameter or TWikiVariable name. 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 ").
{X} expands to the value of the configuration variable {X} - for example, {ScriptUrlPath}
>
>
context True if the current context is set (see below)
allows 'X' allows 'Y' is true if web/topic 'X' exists and allows access mode 'Y' for the current user. Web access rights are only checked if there is no topic called 'X'.
istopic istopic 'X' is true if topic 'X' exists
isweb isweb 'X' is true if web 'X' exists
ingroup 'X' ingroup 'Y' is true if user 'X' is in group 'Y'. 'X' can be a login name or a wikiname.
defined True if a preference variable or url parameter of this name is defined.
$ expands a URL parameter or TWikiVariable name. 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 ").
{X} expands to the value of the configuration variable {X} - for example, {ScriptUrlPath}
  Examples:
Line: 91 to 91
  Context identifiers are used in TWiki to label various stages of the rendering process. They are especially useful for skin authors to find out where they are in the rendering process. The following context identifiers are available:
id context
Changed:
<
<
absolute_urls Set if absolute URLs are required
attach in attach script (see TWikiScripts)
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 TWikiScripts)
command_line the running script was run from the command line, and not from CGI
diff in rdiff script (see TWikiScripts)
edit in edit script (see 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
login & logon in login / logon script (see TWikiScripts)
manage in manage script (see TWikiScripts)
mirror if this is a mirror
new_topic if the topic doesn't already exist
oops in oops script (see TWikiScripts)
preview in preview script (see TWikiScripts)
register in register script (see TWikiScripts)
rename in rename script (see TWikiScripts)
resetpasswd in resetpasswd script (see TWikiScripts)
rss if this is an RSS skin rendering
save in save script (see TWikiScripts)
search in search script (see TWikiScripts)
statistics in statistics script (see TWikiScripts)
textareas_hijacked provided for use by editors that highjack textareas, and want to signal this fact. This is used by skins, for example, so they can suppress extra controls when textareas have been hijacked.
upload in upload script (see TWikiScripts)
view in view script (see TWikiScripts)
viewfile in viewfile script (see TWikiScripts)
rest in rest script (see TWikiScripts)
registration_supported registration is supported by the current UserMapper
registration_enabled set if {Register}{EnableNewUserRegistration} is on, and registrationis supported
passwords_modifyable set if the password manager support changing the password / email
>
>
absolute_urls Set if absolute URLs are required
attach in attach script (see TWikiScripts)
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 TWikiScripts)
command_line the running script was run from the command line, and not from CGI
diff in rdiff script (see TWikiScripts)
edit in edit script (see 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
login & logon in login / logon script (see TWikiScripts)
manage in manage script (see TWikiScripts)
mirror if this is a mirror
new_topic if the topic doesn't already exist
oops in oops script (see TWikiScripts)
preview in preview script (see TWikiScripts)
register in register script (see TWikiScripts)
rename in rename script (see TWikiScripts)
resetpasswd in resetpasswd script (see TWikiScripts)
rss if this is an RSS skin rendering
save in save script (see TWikiScripts)
search in search script (see TWikiScripts)
statistics in statistics script (see TWikiScripts)
textareas_hijacked provided for use by editors that highjack textareas, and want to signal this fact. This is used by skins, for example, so they can suppress extra controls when textareas have been hijacked.
upload in upload script (see TWikiScripts)
view in view script (see TWikiScripts)
viewfile in viewfile script (see TWikiScripts)
rest in rest script (see TWikiScripts)
registration_supported registration is supported by the current UserMapper
registration_enabled set if {Register}{EnableNewUserRegistration} is on, and registrationis supported
passwords_modifyable set if the password manager support changing the password / email
  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.
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 1999-2024 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.IfStatements.