SwitchToAndFromDraft

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

Description

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

Procedure

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 ]])-]
(:if:)

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 ]]
(:if:)

Notes

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'] = '';

--Hagan

Comments

See Also

Contributors

  • 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.