From Jazilla

PmWiki: ConditionalMarkup


The generic form of the (:if:) directive is

(:if cond param:)

where "cond" names a condition to be tested from the $Conditions array, and "param" is a parameter or other argument held in $condparm in the test. For example, the following (in config.php) adds (:if group GroupName:) as a markup:

$Conditions['group'] = "FmtPageName('\$Group',\$pagename)==\$condparm";

One could then use the following markup:

(:if group PmWiki:) This text only appears in the group "PmWiki"(:if:)

The negated form of (:if:) is automatically handled as well, thus:

(:if ! group PmWiki:) This text appears everywhere *but* in group "PmWiki"(:if:)

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

(:if group PmWiki:) Do this in PmWiki group
(:if group Main:) Do something else for Main
(:if:) This happens in all groups

All that remains now is to come up with a good set of $Conditions. Testing for group membership is a good one, we might also want to create something for generic pagename pattern matches

(:if match ^PmWiki\. :) Only appears in the PmWiki group
(:if match RecentChanges$ :) Everywhere except RecentChanges pages
(:if ! match ^(Main|PmWiki)\. :) All groups except Main and PmWiki
(:if:)again - all groups

$Conditions could also be conditional on other items; e.g., date or time, day of week, etc.

samples for if-markups / $Conditions:

(:if group GROUPNAME:) - display following text only, if group = specified groupname:
$Conditions['group'] = "FmtPageName('\$Group',\$pagename)==\$condparm";

(:if author AUTHORNAME:) - display following text only, if author = specified authorname:
$Conditions['author'] = "\$GLOBALS['Author']==\$condparm";
will only work, if Author is "logged" on or has already put his name into the author-field while editing a page, i.e. the global variable $Author must be set

see also: Cookbook:MultiLanguage

I'd like to know if it's possible to check if a user is authenticated as either "editor" or "admin" (in terms of permission to edit pmwiki pages), and then either hide or display the "Edit This Page" link depending on if the user is allowed to edit the page or not - Steven Leite (Nov 25/04)
Retrieved from
Page last modified on January 02, 2005, at 08:32 PM

PmWiki can't process your request

Cannot acquire lockfile

We are sorry for any inconvenience.