PmWiki /
Conditional Markup
Sök:  

Menu

Världen

Folk

Regler

Alternativa Spelregelsystem

Länkar

Trudvang Wiki

authors, admins (advanced)

Using the (:if:) Directive

The (:if:) directive allows portions of a page to be included or excluded from processing. The generic form of the (:if:) directive is

    (: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:

    (:if name PAGENAME:)         - current page is named "PAGENAME"
    (:if group GROUPNAME:)       - current group is named "GROUPNAME"
    (:if auth LEVEL:)            - viewer is authorized at "LEVEL"
                                   where LEVEL can be : read, edit,
                                   upload, attr or admin  
    (:if authid:)                - current viewer is authenticated
    (:if true:)                  - always include text
    (:if false:)                 - always exclude text (same as a comment)
    (:if attachments:)           - current page has attachments
    (:if date DATE:)             - true if current date is DATE
    (:if date DATE..:)           - true if current date is DATE or later (unlimited)    
    (:if date DATE1..DATE2:)     - true if current date is in range DATE1 to DATE2 (inclusive)
                                   (dates are in the format yyyy-mm-dd or yyyymmdd)
    (:if enabled VAR:)           - true if PHP VAR is true
    (:if equal STRING1 STRING2:) - true if STRING1 equals STRING2
    (:if match REG_EXPRESSION:)  - true if current page name matches 
                                   the regular expression

Negated forms of conditions also work

    (:if !attachments:) This page has no attachments

Any (:if:) automatically terminates the previous one, thus markup can be easily cased:

    (:if auth read:)* You can read
    (:if auth edit:)* You can edit
    (:if auth upload:)* You can upload
    (:ifend:)

admins (advanced)

Creating new conditions

See Cookbook:ConditionalMarkupSamples.

« InterMap | DocumentationIndex | Page variables »

Sidan senast ändrad 2006-01-13 kl. 00:35

Skriv ut

Denna webbplats och allt dess innehåll är upphovsrättsskyddad. © Peter Brink 2005, de enskilda sidorna är © respektive författare 2005. Se vidare våra användarvillkor.