Difference: IfStatements (2 vs. 3)

Revision 32006-06-25 - TWikiContributor

Line: 4 to 4
  In the example above, if CONDITION evaluates to TRUE, then THEN will be included in the topic; otherwise ELSE will be included.
Changed:
<
<
What can be included in the THEN and ELSE parameters is obviously limited by standard TWiki syntax for parameters. The best way to use this feature is to define two TWikiVariables, one for the THEN case and the other for the ELSE case. For example:
<!--
   * Set LI = Fred is here!
   * Set LO = Fred is there!
-->
%IF{"context authenticated and defined WIKINAME and $ WIKINAME='FredBloggs'" then="%LI%" else="%LO%"}%
>
>
What can be included in the THEN and ELSE parameters is obviously limited by standard TWiki syntax for parameters.
  The basic syntax of a condition is as follows:
Line: 22 to 15
 basexpr ::= atom | uop atom | atom bop basexpr ; uop ::= 'context' | 'defined' | '$' ; bop ::= '=' | '!=' | '>' | '<' | '>=' | '<=' ;
Changed:
<
<
atom ::= context identifier, TWiki variable name, single-quoted string
>
>
atom ::= context identifier, TWiki variable name, single-quoted string, or configuration item
 
Operators
and True if both sides are true
Line: 32 to 25
 
<, >, <=, >= 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.
Changed:
<
<
$ expands a URL parameter or TWikiVariable. 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 quoted string may not contain quotes (' or ").
>
>
$ expands a URL parameter or TWikiVariable. 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:
Added:
>
>
TWiki variable defined or not
 WIKINAME is defined

You are not allowed to edit this TWiki today.

Added:
>
>
URL parameter
 No search passed in
Added:
>
>
Configuration item set or not User details are hidden
 url param t is out of range.
Added:
>
>
Text comparison
 
Deleted:
<
<
Given
  • Set OPEN_DAY = yes
this expands to:
 
Changed:
<
<
You are not allowed to edit this TWiki today.
>
>
Configuration items are defined in configure. You cannot see the value of a configuration item, you can only see if the item is set or not.
 
Changed:
<
<
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:
>
>
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
<-- -->
Sorted ascending
authenticated a user is authenticated
absolute_urls Set if absolute URLs are required
Line: 77 to 72
 
view in view script (see TWikiScripts)
rest in rest script (see TWikiScripts)
Changed:
<
<
In addition there is an identifier for each enabled plugin; for example, if GallousBreeksPlugin is installed and enabled, then the context ID GallousBreeksPluginEnabled will be set.
>
>
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.
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 1999-2020 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.