Rename Space Page Snippet
This snippet shows a convenient way to move/rename all pages from a space into another. It shows also how to receive input from the user. Just copy the snippet into a new page.Code
1 Rename Space
#if($request.space)
#if("doRename"==$request.op)
#set($space=$request.space)
#foreach($item in $xwiki.getSpaceDocsName($request.space))
$xwiki.getDocument("${space}.${item}").rename("${request.newname}.${item.replace('.','_')}")
#end
1.1 Renamed space $space to $request.newname
[Cancel>$doc.fullName]
#end
#if("listRename"==$request.op)
#set($space=$request.space)
1.1 Renaming space $space to $request.newname
#foreach($item in $xwiki.getSpaceDocsName($request.space))
* Renaming $space.$item to ${request.newname}.${item.replace('.','_')}
#end
[Confirm>$doc.fullName?space=$space&newname=$request.newname&op=doRename]
[Cancel>$doc.fullName]
#end
#if("getNewName"==$request.op)
Renaming $request.space
1.1 Renaming ${request.space}
<form method="post" action="$doc.getURL("view", "")" onsubmit="cancelCancelEdit()">
<div class="padded centered">
<input type="hidden" name="space" value="${request.space}" />
<input type="hidden" name="op" value="listRename" />
Enter new name for the space:
<input type="text" name="newname" value="${request.space}" class="panelinput" style="margin:auto;" onfocus="if(this.value=='Title') this.value=''" onblur="if(this.value=='') this.value='Title'"/>
</div>
<div class="padded centered" style="text-align:center;">
<input type="submit" class="button" style="margin:auto;" value="Rename"/>
</div>
</form>
[Cancel>$doc.fullName]
#end
#else
{table}
Space | Action
#foreach($space in $xwiki.spaces)
$space | [Rename>$doc.fullName?space=${space}&op=getNewName]
#end
{table}
#end
Version 4.1 last modified by VincentMassol on 26/02/2008 at 09:01
Document data
Attachments:
No attachments for this document
Comments: 1