Wiki source code of [Deprecated] Manually create automatic redirect to new document
Last modified by Irina Hrehorciuc on 2022/05/03 09:30
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | 1. [[Create a document>>http://test.xwiki.org/xwiki/bin/view/Nested+Spaces/Create+a+Nested+Document+using+Add+button]] http:~/~/127.0.0.1:8080/xwiki/bin/view/1/ | ||
2 | 1. Bookmark this document in your browser | ||
3 | 1. [[Create a second document>>http://test.xwiki.org/xwiki/bin/view/Nested+Spaces/Create+a+Nested+Document+using+Add+button]] http:~/~/127.0.0.1:8080/xwiki/bin/view/A/ | ||
4 | 1. Create a separate page to run the following [[velocity>>extensions:Extension.Velocity Macro]] script. The script will allow you to move document 1 to be a child document of A | ||
5 | {{code language="velocity"}}{{velocity}} | ||
6 | #set ($source = $services.model.resolveSpace('1')) | ||
7 | #set ($destination = $services.model.resolveSpace('A')) | ||
8 | $services.refactoring.move($source, $destination).join() | ||
9 | {{/velocity}}{{/code}} | ||
10 | 1. Go back to http:~/~/127.0.0.1:8080/xwiki/bin/view/1/ and recreate this page. In edit mode add the following redirect snippet and then save the page. | ||
11 | {{code language="velocity"}}{{velocity}} | ||
12 | $response.sendRedirect($xwiki.getURL('A.1')) | ||
13 | {{/velocity}}{{/code}} | ||
14 | 1. Click on the bookmark you made earlier. |