DynamicPageActions

Summary: Dynamic PageActions
Version: 1.1
Prerequisites: PmWiki 2.1.beta33 or later, AuthUser or UserAuth
Status:
Maintainer: hartwork

Questions answered by this recipe

How can I show/hide certain page actions for logged-out users? This section is optional; use it to indicate the types of questions (if any) this recipe is intended to answer.

Description

This recipe provides a Site.PageActions page that adapts itself according to the current login status and page action.
This table shows under what conditions a button is available:

Button Condition
Attach Logged in, upload allowed
Edit Logged in, action not "edit"
History Logged in, action not "diff"
Login Not logged in
Logout Logged in
Print Action not "print"
Search true
View Action not "browse"

Installation

These files have to be modified:

  • config.php
  • Site.PageActions

config.php

Add these lines to you local/config.php:

# Provide action conditional (:if action ACTION:)
$Conditions['action'] = '\$GLOBALS["action"]==\$condparm';
# Viewing the diff also requires "edit" rights
# which logged-out users usually don't have.
# Thanks for this to Hagan Fox.
$HandleAuth['diff'] = 'edit';

Site.PageActions

This recipe works with AuthUser or UserAuth.
Choose one of these two:

Variant for AuthUser

Change your Site.PageActions to:

* [[{$FullName}?action=search | $[Search] ]]
(:if ( ! action browse ) :)
* %item class=browse accesskey='$[ak_view]'%[[{$FullName} | $[View] ]]
(:if ( auth edit && ! action edit ) :)
* %item rel=nofollow class=edit accesskey='$[ak_edit]'%[[{$FullName}?action=edit | $[Edit] ]]
(:if ( auth edit && ! action diff ) :)
* %item rel=nofollow class=diff accesskey='$[ak_history]'%[[{$FullName}?action=diff | $[History] ]]
(:if ( auth upload ) :)
* %item rel=nofollow class=upload accesskey='$[ak_attach]'%[[{$FullName}?action=upload | $[Attach] ]]
(:if ( ! action print ) :)
* %item rel=nofollow class=print accesskey='$[ak_print]'%[[{$FullName}?action=print | $[Print] ]]
(:if ( authid ) :)
* %item rel=nofollow class=logout accesskey='$[ak_login]'%[[{$FullName}?action=logout | $[Logout] ]]
(:if ( ! authid ):)
* %item rel=nofollow class=login accesskey='$[ak_logout]'%[[{$FullName}?action=login | $[Login] ]]
(:if:)

Variant for UserAuth

Change your Site.PageActions to:

* [[{$FullName}?action=search | $[Search] ]]
(:if ( ! action browse ) :)
* %item class=browse accesskey='$[ak_view]'%[[{$FullName} | $[View] ]]
(:if ( loggedin && ! action edit ) :)
* %item rel=nofollow class=edit accesskey='$[ak_edit]'%[[{$FullName}?action=edit | $[Edit] ]]
(:if ( loggedin && ! action diff ) :)
* %item rel=nofollow class=diff accesskey='$[ak_history]'%[[{$FullName}?action=diff | $[History] ]]
(:if ( loggedin && auth upload ) :)
* %item rel=nofollow class=upload accesskey='$[ak_attach]'%[[{$FullName}?action=upload | $[Attach] ]]
(:if ( ! action print ) :)
* %item rel=nofollow class=print accesskey='$[ak_print]'%[[{$FullName}?action=print | $[Print] ]]
(:if ( loggedin ) :)
* %item rel=nofollow class=logout accesskey='$[ak_login]'%[[{$FullName}?action=logout | $[Logout] ]]
(:if ( ! loggedin ) :)
* %item rel=nofollow class=login accesskey='$[ak_logout]'%[[{$FullName}?action=login | $[Login] ]]
(:if:)

Notes

Tested with PmWiki 2.1.2
Don't use with StaticPages as the generated pages won't have all actions on it.

Release Notes

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

See Also

AuthUser
UserAuth
PmWiki as a CMS
Bookmarklet an alternative approach to provide "clean" pages for visitors, but action links for editors.

Contributors

Comments

See discussion at DynamicPageActions-Talk

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.