The (:if:)
directive allows portions of a page to be included or
excluded from processing. The generic form of the (:if:)
directive is
%indent% (:if cond param:) body (:ifend:)
where "cond" names a condition to be tested (described below), and "param"
is a parameter or other argument to the condition.
The built-in conditions include:
%indent% |
|
- |
current page is named " |
|
- |
current group is named " | |
|
- |
viewer is authorized at " | |
|
- |
current viewer is authenticated | |
|
- |
always include text | |
|
- |
always exclude text (same as a comment) | |
|
- |
current page has attachments | |
|
- |
true if current date is | |
|
- |
true if current date is | |
|
- |
true if current date is in range | |
%green center%dates are in the format yyyy-mm-dd or yyyymmdd | |||
|
- |
true if PHP VAR is true | |
|
- |
true if user has entered any password during the current browser session. | |
|
- |
true if | |
|
- |
true if current page name matches the regular expression | |
|
- |
true if the page pagename exists |
Negated forms of conditions also work:
%indent% |
|
- |
this page has no attachments |
| |||
|
current page is NOT named " | ||
|
|||
|
Any (:if:)
automatically terminates the previous one, thus markup can be
easily cased (and are not nested):
%indent% (:if enabled AuthPw:)* You're logged in
%indent% (:if auth read:)* You can read
%indent% (:if auth edit:)* You can edit
%indent% (:if auth upload:)* You can upload
%indent% (:ifend:)
The character *
can be used as a wildcard to represent any character,
zero, one or multiple times.
The character ?
can be used as a wildcard to represent any character
exactly one time.
Wildcard characters (*
and ?
) can be used in conditional markup,
thus:
%indent% |
|
- |
current page is in group PmCal and begins with 2005 |
|
- |
current page is in group PmWiki or a group beginning with Pmwiki | |
|
- |
current page is in group |
Conditions (as previously defined) may be combined into more complex
conditional expressions using one of these three equivalent forms:
%indent% (:if expr EXPRESSION :)
%indent% (:if [ EXPRESSION ] :)
%indent% (:if ( EXPRESSION ) :)
Conditions are combined into expressions with boolean operators and
brackets. In the next table, A and B are either regular conditions or
bracketed sub-expressions of regular conditions:
>>indent<<
|| border=1 cellpadding=2 cellspacing=0
||! Expression ||! Operator ||! Result ||
|| A and B
|| And ||TRUE if both A and B are TRUE.||
|| A or B
|| Or ||TRUE if either A or B is TRUE.||
|| A xor B
|| Xor ||TRUE if either A or B is TRUE, but not both.||
|| ! A
|| Not ||TRUE if A is not TRUE.||
|| A && B
|| And ||TRUE if both A and B are TRUE.||
|| A || B
|| Or ||TRUE if either A or B is TRUE.||
>><<
Nota:
Thus, writing:
%indent% (:if expr auth admin || auth attr || auth edit :)
%indent% [[Logout -> {$Name}?action=logout]]
%indent% (:if:)
provides you a logout link only when authentified with rights higher than 'read'.