Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

MovePage

Summary: Move and copy wiki pages
Version: 2009-08-17
Prerequisites: PmWiki 2.2.x
Status: production
Maintainer: Eemeli Aro
Discussion: MovePage-Talk
Download: movepage.phpΔ

Description

MovePage provides a simple form and simple actions to copy or move/rename a page within a wiki. It creates a redirect to the new page at the old page.

To use, once installed, add ?action=copy or ?action=move to a page's location (or use a PageActions link, if you've defined one) to get a simple form, fill in the target name and press a button ("Copy" or "Move"). MovePage will verify that the target page doesn't already exist, and that you have the required permissions, then moves or copies the page including all of its history, as well as adding a note in the page history & recent changes that the copy/move has been made.

Installation

  • Download movepage.phpΔ to your cookbook directory
  • Add the following to your config file:
    if (($action=='copy') || ($action=='move')) include_once("$FarmD/cookbook/movepage.php");
  • Optionally, add something like the following to your Site.PageActions page:
    (:if auth edit:)
    * %item rel=nofollow class=move% [[{*$FullName}?action=move | $[Copy/move] ]]
    (:ifend:)
    

Configuration

MovePage is configured via an array $MovePageFmt, which contains the following entries. These are all interpreted in the context of the source page, hence the use of a new page variable {$MoveTargetName}.

$MovePageFmt['copy-csum']
default 'Page copied to {$MoveTargetName} from {$FullName}'
The change summary to leave on a copied target page.
$MovePageFmt['move-csum']
default 'Page moved to {$MoveTargetName} from {$FullName}'
The change summary to leave on a moved target page.
$MovePageFmt['old-csum']
default 'Page moved to {$MoveTargetName}'
The change summary to leave on a moved source page, if it is not deleted.
$MovePageFmt['old-text']
default '(:redirect {$MoveTargetName}:)'
The text to leave on a moved source page. Use $MovePageFmt['old-text'] = 'delete'; to delete the source page when moving.
$MovePageFmt['form']
The form used to copy or move a page. See the source for the default value or below for an equivalent in wiki markup.

Custom copy/move form

To modify the form used, you'll need to define your own form as a wiki page, such as Site.MoveForm and then set the following in a config file:

$MovePageFmt['form'] = 'wiki:Site.MoveForm';

Here's how to re-implement the default form using wiki markup:

>>wikimove<<
!! %block wikiaction% $[Copy/move] {*$FullName} $[to:]
(:input form "{*$PageUrl}?action=move" post:)
(:input hidden n {*$FullName}:)
(:input text to {*$MoveTargetName}:)
(:input submit copy $[Copy]:)
(:input submit move $[Move]:)
(:input submit cancel $[Cancel]:)
(:input end:)

(:messages:)
>><<

Copy/move Cookbook.MovePage to:

Notes

If you want, you can use MovePage's actions from another recipe or form by POSTing to a location such as {$PageUrl}?action=copy or {$PageUrl}?action=move with a single POST parameter to=New.Name. to as a GET parameter is explicitly not handled, as that might result more easily in accidental use.

RenamePage has done pretty much this since 2005, but it's broken enough things on my sites for me to have disabled it. I also couldn't be bothered to look through its code to figure out all that it does.

Release notes

See also

Contributors

Comments


This space is for User-contributed commentary and notes. Please include your name and a date (eg 2007-05-19) along with your comment. Please leave new comments at the top of this section.

It seems this line is not necessary, since most Page Manipulation routine is handles UTF-8 encoded path w/o problem. I can't rename a page into a 'Chinese file name' unless I comment out this line.

   if (preg_match('/[\\x80-\\xbf]/', $tgtname)) $tgtname = utf8_decode($tgtname);

I have some problems with Pagelists and Conditions

I installed the Cookbook Cookbook.MovePage. As soon a page ist moved from the Group e.g. "Shows" to "Showsarchive" it still exists in the group "Shows". Therefore I want to give out all the "Shows.*" pages in a pagelists but not showing the pages that are already in the group "Showsarchive.*".

It should be a conditions something like this:

(:pagelist group="Shows" fmt="#simple" if="!group Showsarchive.*" :)

But i have not clue and invested already hours in finding out. Maybe you can help me? That would save my day! Jean Baptiste On May 24, 2010 - at 13:28 PM

I just found out, Yeah:

(:pagelist group="Shows" fmt="#simple" if="!exists Showsarchive.{=$Name}"
:)

Jean Baptiste On May 26, 2010 - at 1:13 AM

Are you sure you're moving these pages instead of copying them? Moving should remove the page from the original group; if that's not happening then there's a bug. However, if you're copying pages then your solution is a good one. —Eemeli Aro
My experience was that "move" changes the original to redirect to the new page - but the original still exists. If it didn't do that, links to the original would be broken - so for some installations that might not be a bug. However, if you need to be able to test whether the original is redirecting, perhaps the recipe can be modified to include on the original page a page text variable such as "moved: newname" - then moved pages can be tested by a conditional. - RandyB May 26, 2010, at 12:56 PM

Jazzvox on Dec 07, 2011 - at 11:55 CET

Use CleanUp in addition, or delete moved pages manually. It's the way it should be.

User notes +6: 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.

Edit - History - Print - Recent Changes - Search
Page last modified on August 29, 2014, at 03:11 PM