%IFDEFINED{"string" then="..." else="..."}%
tag that returns the then
or else
argument depending on the string
being defined, that is non-empty. There are no other ways to decide the condition but rendering the test
string being a TWikiML expression, for example by embedding a %CALC{}%
expression. This simplifies this plugin alot and allows a rather flexible way to generate the condition.
The other way is to use blocks of content surrounded by expressions like this:
%IFDEFINEDTHEN{"test"}% ... %ELSIFDEFINED{"test"}% ... %ELSEDEFINED% ... %FIDEFINED%This way the conditioned content is not limited to fit into a the argument position of a
%IFDEFINED{...}%
expression. Blocks can be nested and are evaluated starting from the outside, contrary to standard TWikiML being evaluated left-to-right-inside-out.
%IFDEFINED{"test" [action="view,edit,preview,..."]? [as="..."] then="..." else="..." glue="on,off"}%returns the "then or "else" content depending on the "test" expression expanding to the empty string or matching the string given in "as". Optionally the current topic action is checked to match the one given in "action". Normally, all surrounding whitespaces are removed, that is the resulting content is glued together in a way. You may switch that off by setting "glue" to "off" thus preventing all whitespace as it is. The "then" and "else" strings may contain the following pseudo-variables:
$n
: substituted with a newline character (\n)
$percnt
: substituted with a percent character (%)
$dollar
: substituted with a dollar character ($)
$test
or $variable
: substituted with the "test" string
$value
: substituted with the "as" string
%IFDEFINEDTHEN{"test" [action="view,edit,preview,..."]?}% <then content> [%ELSIFDEFINED{...}% <elsif content>]* [%ELSEDEFINED% <else content>]? %FIDEFINED%This is the multi-line version of IFSDEFINED. IFDEFINEDTHEN expressions can be nested safely. Within a single IFDEFINEDTHEN the ELSIFDEFINED parts can be repeated arbitrarily. Before rendering the
<then|elsif|else condition>
any $nop
string will be removed first. Thereby nested TWikiML expressions can be prevented from being expanded in advance.
%IFACCESS% %IFACCESS{"<webtopic>" [type="view|change"] [user="<WikiName>"] [then="<then-clause>"] [else="<else-clause>"] [glue="on|off"]}%This checks the access permissions a user has on a given topic and then renders the
<then-clause>
if access is granted and lt;else-clause>
otherwise. By default, the current user's view access will be checked on the current topic (%IFACCESS%
). The other parameters are:
<webtopic>
: the name of the topic to be checked, defaults to current
user="<WikiName>"
: the name of the user to be checked, defaults to the current user
type="view|change"
: the type of access to be checked, either view access or change/edit access, defaults to "view"
then="<then-clause>"
: the string to be returned on granted access, defaults to "1"
else="<else-clause>"
: the string to be returned if no access is granted, defaults to "0"
glue="on|off"
: apply glue around the IFACCESS tag or not, defaults to "on"
%IFEXISTS{"<webtopic>" [then="<then-clause>"] [else="<else-clause>"] [glue="on|off"]}%This tag checks if
webtopic
exists and expands then-clause
or else-clause
as needed. A similar functionality is available using %CALC{"$IF($EXIST(<webtopic>,<then-clause>),<else-clause>)"}%
of the SpreadSheetPlugin. This is still preferable if you need more computation based on CALC in the then/else branches. The IFEXISTS version however is more lightweigted, comes with a much simpler syntax and allows more complex TWikiMarkup in the then/else branches.
|
|||||||
configure
in your TWiki installation, and enable the plugin in the {Plugins} section.
|
|||||||||||||||||||||||||||||||||||||||||||||
Copyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Linux® is the registered trademark of Linus Torvalds in the U.S. and other countries.
Microchip and others, are registered trademarks or trademarks of Microchip Technology Inc. and its subsidiaries.
Arm® and others are registered trademarks or trademarks of Arm Limited (or its affiliates). Other terms and product names may be trademarks of others.
Ideas, requests, contributions ? Connect to LinksToCommunities page.