Difference: IfStatements (8 vs. 9)

Revision 92010-05-08 - 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: 17 to 17
 
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.
Added:
>
>
isempty True if a preference variable, url parameter or session variable of this name has an empty value. It is equivalent to the expression (defined(x) || $x='')
 
$ 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}
Line: 87 to 88
 expands to:
You are a normal user
Added:
>
>
11. Hide section of text conditionally using CSS visibility
<div style="visibility: %IF{"'%USERNAME%' ingroup 'TWikiAdminGroup'" then="visible" else="hidden"}%">
   * Conditional text enclosed in div tags here...
   * ...can be as long as needed
</div>
Above text is only shown to users who are in the TWikiAdminGroup.
 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.

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:

Line: 131 to 141
 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.

Note also that while the query syntax can be used to access form fields, there are some contexts in which an IF statement may be used where there is no topic context, or the topic context is not what you expected.

Added:
>
>
Related Topics: QuerySearch, VarIF, VarSEARCH, FormattedSearch

-- Contributors: TWiki:Main/ArthurClemens, TWiki:Main/CrawfordCurrie, TWiki:Main/PeterThoeny, TWiki:Main/SopanShewale, TWiki:Main/SvenDowideit, TWiki:Main/WillNorris - 2010-04-09

 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 1999-2019 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.