Summary: Provide a sidebar or PageActions link to switch to/from -Draft pages
Version: Initial
Prerequisites: PmWiki 2.1 (?)
Status: Quo
Categories: CMS Editing


Put a link in the SideBar or PageActions so authors can easily switch to and from a -Draft version of a page.


Put this in a local configuration file (config.php):

## Enable (:if enabled EditDraft:) for a page that has a -Draft version and
## (:if enabled PageIsDraft:) with {$DraftBaseName} page variable for -Draft pages.
$pagename = ResolvePageName($pagename);
if (CondAuth($pagename, 'edit')) {
  if (PageExists($pagename.'-Draft')) { $EditDraft = TRUE; }
  if (preg_match('/-Draft$/', $pagename)) { $PageIsDraft = TRUE;
    $draftbasename = preg_replace("/-Draft\$/", '', $pagename);
    $FmtPV['$DraftBaseName'] = "'$basename'";
    # $HTMLStylesFmt['isdraft'] = " /* Custom CSS for draft page */ ";

Then you can use markup like this in the sidebar:

(:if enabled EditDraft:)
[-([[{*$FullName}-Draft | View draft ]])-]
(:if enabled PageIsDraft:)
[-([[{*$DraftBaseName} | View published ]])-]

Another possibility is to use this in Site.PageActions:

(:if enabled EditDraft:)
* %item              class=browse    %[[{*$FullName}-Draft | View Draft ]]
(:if enabled PageIsDraft:)
* %item              class=browse    %[[{*$DraftBaseName} | View Published ]]


PmWiki 2.2 beta57 appears to have a bug that disables the Publish button. A workaround might be to add

$DefaultPasswords['publish'] = $DefaultPasswords['edit'];

or possibly

$DefaultPasswords['publish'] = '';



See Also


  • Hagan Fox - Initial recipe inspired by a request from Steve Crisp, who also suggested the PageActions alternative, on the pmwiki-users list.

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.