r2 - 2006-07-07 - 12:13:15 - TWikiAdminGroupYou are here: NTP >  TWiki Web > IfDefinedPlugin
NTP users are strongly urged to take immediate action to ensure that their NTP daemons are not susceptible to being used in distributed denial-of-service (DDoS) attacks. Please also take this opportunity to defeat denial-of-service attacks by implementing Ingress and Egress filtering through BCP38.

ntp-4.2.8p10 was released on 21 March 2017. It addresses 6 medum- and 5 low-severity security issues, 4 informational security topics, 15 bugfixes, and contains other improvements over 4.2.8p9.

Please see the NTP Security Notice for vulnerability and mitigation details.

Are you using Autokey in production? If so, please contact Harlan - he's got some questions for you.



This plugin adds a couple of tags that allow to render content conditionally. There are two different ways to do that: either by using the inline %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 deceide the condition but rendering the string argument using TWikiML, 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:

This way conditioning content is not limited to fit into a TWikiML argument as it is the case using an inline IFDEFINED tag. Blocked conditions can be nested and are evaluated starting from the outside, contrary to standard TWikiML being evaluated left-to-right-inside-out.

Related work

Similar extensions have been done before but are either only available as an integral part of TWiki-4.0 (see TWiki:TWiki04/IfStatements) or unmaintained (see TWiki:Plugins/ConditionalPlugin). Especially these two alternatives are rather similar as they defined the same tag (%IF). The main differences between those and this plugin here is that they have a more elaborated conditon parser that allows to evaluate more complex boolean expressions. Some of the expressions in %IF of TWiki-4.0 are specific to that platform and make only sense there (context). The other difference is that the IFDEFINED tag family allows nested blocks of conditional content and %IF is an inline tag only.

The advantage of this plugin is that you get a simpler mechanism for checking the condition which is however more flexible as the string can be generated arbitrarily using TWikiML. Furthermore, and possibly more important, this plugin is backwards compatible and may be used on a TWiki/Beijing, TWiki/Cairo and TWiki/Dakar engine.

This plugin has been externalized from the TWiki:Plugins/NatSkinPlugin.

Syntax Rules



returns the "then" or "else" content depeinding on the <TWikiML> expression expanding to the emtpy string or to the string given in "as". Optionally the current topic action is checked to match the given one. This tag works similar to the IfStatements in dakar but is backwards compatible to beijing and cairo and omits the overhead of an expression parser.


%IFDEFINEDTHEN{"<TWikiML>" [action="view,edit,preview,..."]?}% 
  <then content> 
  <elsif content>]* 
  <else content>]?

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.


  • Set FOO = foo
  • FOO is %IFDEFINED{"foo" then=" " else="not" glue="off"}% defined.
  • FOO is %IFDEFINED{"foo" as="bar" then=" " else="not" glue="off"}% defined as "bar".
  • BAR is %IFDEFINED{"%BAR%" then=" " else="not" glue="off"}% defined.

Plugin Settings

  • Set SHORTDESCRIPTION = Render content conditionally

Plugin Installation Instructions

  • Download the ZIP file
  • Unzip it in your twiki installation directory. Content:
    File: Description:
    data/TWiki/IfDefinedPlugin.txt Plugin topic
    lib/TWiki/Plugins/IfDefinedPlugin.pm Plugin Perl module

Plugin Info

Plugin Author: TWiki:Main.MichaelDaum
Copyright ©: 2006, Michael Daum
License: GPL (GNU General Public License)
Plugin Version: v0.91
Change History:  
10 Mar 2006: added as parameter; added escape parameters and recursive variable expansion to the condition argument which helps to circumvent problems due to different plugin orders
21 Feb 2006: Initial version
CPAN Dependencies: none
Other Dependencies: none
Perl Version: 5.8
TWiki:Plugins/Benchmark: GoodStyle nn%, FormattedSearch nn%, IfDefinedPlugin nn%
Plugin Home: TWiki:Plugins/IfDefinedPlugin
Feedback: TWiki:Plugins/IfDefinedPluginDev

-- TWiki:Main.MichaelDaum - 10 Mar 2006

Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r2 < r1 | More topic actions
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding NTP? Send feedback
Note: Please contribute updates to this topic on TWiki.org at TWiki:TWiki.IfDefinedPlugin