Main.SideBar (edit)
Phoenix ProjectSectionsActivitiesEquipmentPeopleResourcesLinksAbout Wikis |
SyntaxThe generic form of the (:if:) directive is
(:if cond param:) body (:if:)
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
See also Cookbook:ExpandingMenus for an example to use this to create compact Sidebar menus.
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
There is an (:if auth ...:) conditional markup available for processing depending on the current authorizations in effect. For example, one can create a bullet list with
(:if auth read:)* [[View page -> {$Name}?action=browse]]
(:if auth edit:)* [[Edit page -> {$Name}?action=edit]]
(:if auth upload:)* [[Attachments -> {$Name}?action=upload]]
(:if auth attr:)* [[Page Attributes -> {$Name}?action=attr]]
(:if auth admin:)* You're logged in as admin
(:ifend:)
and only those items corresponding to the user’s current authorizations will appear. This should be very useful in creating action buttons.
$Conditions could also be conditional on other items; e.g., date or time, day of week, etc.
Default PmWiki ConditionsThe following are defined in pmwiki.php, so would not need to be defined in config.php:
$Conditions['false'] = 'false';
$Conditions['true'] = 'true';
$Conditions['group'] = "FmtPageName('\$Group',\$pagename)==\$condparm";
$Conditions['name'] = "FmtPageName('\$Name',\$pagename)==\$condparm";
$Conditions['match'] = 'preg_match("!$condparm!",$pagename)';
$Conditions['auth'] = '@$GLOBALS["PCache"][$GLOBALS["pagename"]]["=auth"][trim($condparm)]';
$Conditions['authid'] = '@$GLOBALS["AuthId"] > ""';
Samples for if-markups /
|