#!/usr/local/bin/php
Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /cgihome/cis520/html/dynamic/2016/wiki/pmwiki.php on line 691
Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /cgihome/cis520/html/dynamic/2016/wiki/pmwiki.php on line 694
Warning: Use of undefined constant MathJaxInlineCallback - assumed 'MathJaxInlineCallback' (this will throw an Error in a future version of PHP) in /cgihome/cis520/html/dynamic/2016/wiki/cookbook/MathJax.php on line 84
Warning: Use of undefined constant MathJaxEquationCallback - assumed 'MathJaxEquationCallback' (this will throw an Error in a future version of PHP) in /cgihome/cis520/html/dynamic/2016/wiki/cookbook/MathJax.php on line 88
Warning: Use of undefined constant MathJaxLatexeqrefCallback - assumed 'MathJaxLatexeqrefCallback' (this will throw an Error in a future version of PHP) in /cgihome/cis520/html/dynamic/2016/wiki/cookbook/MathJax.php on line 94
PmWiki /
Conditional Markupauthors, admins (advanced)
Using the (:if:) DirectiveThe (:if cond param:) body (:ifend:)
(:if cond param:) body (:else:) body (:ifend:)
(:if cond param:) body (:elseif cond param:) body (:ifend:)
(:if cond param:) body (:elseif cond param:) body (:else:) body (:ifend:)
where “cond” names a condition to be tested, and “param” is a parameter or other argument to the condition. Note that Built-in ConditionsThe built-in conditions include:
The name and group conditionals will work even for an included page, as the “name” and “group” conditionals always check the currently displayed page, as opposed to the page that the markup appears in. Note: Although there is no built-in conditional markup to test ?action=, you can use Concatenated conditionsIn some cases where built in conditions have a parameter the parameters may be concatenated using a comma, viz:
Negated ConditionsNegated forms of conditions also work:
Nesting ConditionsNote that
Conditions can be nested from 2.2.beta 66. To have nested conditionals you need to number the if, and the matching else/ifend: (:if cond1:) cond1 is true (:if2 cond2:) cond1 and cond2 are true (:elseif2 cond3:) cond1 and cond3 are true, cond2 is not (:else2:) cond1 is true, cond2 and cond3 are not (:if2end:) (:else:) cond1 is false, cond2 testing was ignored (:ifend:) Spaces were added for better readability. Using wildcard placeholdersThe character
Using page text variables, page variables and markup expressionsPage text variables (PTVs), page variables (PVs) and markup expressions can be used in conditional markup. They will be assigned/evaluated before the condition(s). Combining conditionsConditions (as previously defined) may be combined into more complex conditional expressions using one of these three equivalent forms: (:if expr EXPRESSION :) (:if [ EXPRESSION ] :) (:if ( EXPRESSION ) :) Conditions are combined into expressions with boolean operators and brackets. In the next table, A and B are either regular conditions or (round-)bracketed sub-expressions of regular conditions:
Example (:if [ name SomePage and group SomeGroup ]:) equivalent to (:if name SomeGroup.SomePage:) Important Notes:
Thus, the following is a valid way of building an expression that shows the following contents only when the user is either the administrator, or is logged in and the time is later than the given date: (:if [ auth admin || ( authid && date 2006-06-01.. ) ] :)
Nesting with square brackets will silently fail to work as expected: (:if [ auth admin || [ authid && date 2006-06-01 ] ] :) NOTE: Doesn’t Work!
A common use of these complex tests are for expressions like: (:if expr auth admin || auth attr || auth edit :)
[[Logout -> {$Name}?action=logout]]
(:ifend:)
which provides a logout link only when the browser has admin, attr, or edit permissions. admins (advanced) Creating new conditionsSee Cookbook:ConditionalMarkupSamples. See also special references for the use of {*$Variables}. This page may have a more recent version on pmwiki.org: PmWiki:ConditionalMarkup, and a talk page: PmWiki:ConditionalMarkup-Talk. |