|
Cookbook /
DynamicPageActionsSummary: Dynamic PageActions
Version: 1.1
Status:
Maintainer: hartwork
Categories: Content Management System Add-Ons
Questions answered by this recipeHow can I show/hide certain page actions for logged-out users? DescriptionThis recipe provides a Site.PageActions page that adapts itself
according to the current login status and page action.
InstallationThese files have to be modified:
config.phpAdd 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.PageActionsThis recipe works with AuthUser or UserAuth. Variant for AuthUserChange 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=login accesskey='$[ak_login]'%[[{$FullName}?action=logout | $[Logout] ]]
(:if ( ! authid ):)
* %item rel=nofollow class=logout accesskey='$[ak_logout]'%[[{$FullName}?action=login | $[Login] ]]
(:if:)
Variant for UserAuthChange 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=login accesskey='$[ak_login]'%[[{$FullName}?action=logout | $[Logout] ]]
(:if ( ! loggedin ) :)
* %item rel=nofollow class=logout accesskey='$[ak_logout]'%[[{$FullName}?action=login | $[Login] ]]
(:if:)
NotesTested with PmWiki 2.1.2 Release Notes
CommentsI was only able to get this to work by inserting an asterix before each $FullName. This is necessary with PmWiki version 2.2.0-beta1 and beyond. i.e.. * [[{*$FullName}?action=search | $[Search] ]]
-- James Yes, thanks James. I found that without the asterisk, $Fullname would resolve to "site.pageActions" instead of the current page when viewing any but site and main groups. -- Dave This does not work without UserAuth? Is it possible to have the Loggin when you're using passwords? Thanks a log- Chris I'm not fully sure what you mean. UserAuth is needed for the "loggedin" conditional. --hartwork
I found a solution for myself. I'm not sure if it's right to add it here. Feel free to move it! If you want a Login when your using Passwords (View - Edit - History - Upload is hidden without a valid pass), your Site.PageActions should have something like this:
(:if !auth edit:)
* %item class=edit accesskey=$[ak_edit]%[[{$FullName}?action=edit | Login ]]
(:if auth edit:)
* %item class=browse accesskey=$[ak_view]%[[{$FullName} | $[View] ]]
(:if auth edit:)
* %item class=edit accesskey=$[ak_edit]%[[{$FullName}?action=edit | $[Edit] ]]
* %item class=diff accesskey=$[ak_history]%[[{$FullName}?action=diff | $[History] ]]
(:if auth upload:)
* %item class=upload accesskey=$[ak_attach]%[[{$FullName}?action=upload | $[Attach] ]]
(:if:)
* %item class=print accesskey=$[ak_print]%[[{$FullName}?action=print | $[Print] ]] }
The Login guides you to a password prompt and then to the edit mode. The View-Edit-History-Upload Buttons appear. If you're using sectionEdit you may want, that the Edit section buttons do appear also after the Login. You have to modify the include_once for this file in your local config to this Code:
if (CondAuth ($pagename, 'edit')) {include_once('cookbook/sectionedit.php');}
Hope someone finds this helpful - Chris. I indeed find this very usefull. Thanks Chris! I wonder why this is not default in PmWiki? - Bastian, 2006-08-24
Now if you want login/logout based strictly on whether a password has been used in the session, you can use
(:if !enabled AuthPw:)
* [[{$FullName}?action=login | Login ]]
(:if enabled AuthPw:)
* [[Main/HomePage?action=logout | Logout ]]
A lot like Cookbook/AuthUserCMSLike, but with a different page. So, perhaps the two recipes should be merged? This is my code for UserAuth 0.70:
* item class=browse accesskey='$[ak_view]' [[{$FullName} | $[View] ]]
(:if loggedin:)
* item rel=nofollow class=edit accesskey='$[ak_edit]' [[{$FullName}?action=edit | $[Edit] ]]
* item rel=nofollow class=diff accesskey='$[ak_history]' [[{$FullName}?action=diff | $[History] ]]
(:if:)
(:if auth upload:)(:if loggedin:)
* item rel=nofollow class=upload accesskey='$[ak_attach]'%25[[{$FullName}?action=upload | $[Attach] ]]
(:if:)(:if:)
* item rel=nofollow class=print accesskey='$[ak_print]'%25[[{$FullName}?action=print | $[Print] ]]
Maybe be helpfull. See AlsoAuthUser Contributors
User notes?: If you use, used or reviewed this recipe, you can add your name. The following format is recognized:
* (+) Optional positive comment. Name, date * (-) Optional negative comment. Name, date These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki. |