From version 12.1
To version < 13.1
edited by Gunter Ohrner
on 2020/01/28 17:02
Change comment: Migrated property [author] from class [XWiki.XWikiComments]

Summary

Details

Page properties
Parent
... ... @@ -1,0 +1,1 @@
1 +Extension.WebHome
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.XWikiGuest
1 +xwiki:XWiki.GOhrner
Content
EXOExtensionCode.ExtensionClass[0]
ExtensionCode.ExtensionClass[0]
Description
... ... @@ -1,0 +1,83 @@
1 +Once the snippet is added to a page, if you come back to that page in "view" mode you will be automatically sent to the page defined between the brackets.
2 +
3 +== Examples ==
4 +
5 +=== Basic Redirects ===
6 +
7 +* Send the user to an external website
8 +
9 +{{code language="none"}}
10 +$response.sendRedirect("http://www.w3.org")
11 +{{/code}}
12 +
13 +* Send the user to another page on the wiki
14 +
15 +{{code language="none"}}
16 +$response.sendRedirect($xwiki.getURL('Some.Document'))
17 +{{/code}}
18 +
19 +* Send the user to another page on the wiki, in edit mode
20 +
21 +{{code language="none"}}
22 +$response.sendRedirect($xwiki.getURL('Some.Document', 'edit'))
23 +{{/code}}
24 +
25 +* Send the user directly to the edit mode of the page viewed
26 +
27 +{{code language="none"}}
28 +$response.sendRedirect($doc.getURL('edit'))
29 +{{/code}}
30 +
31 +=== Advanced Redirects ===
32 +
33 +* Show the same page to the user but without applying the skin
34 +
35 +{{code language="none"}}
36 +$response.sendRedirect($doc.getURL('view', 'xpage=plain'))
37 +{{/code}}
38 +
39 +* Show the same page in wiki markup language but without applying the skin
40 +
41 +{{code language="none"}}
42 +$response.sendRedirect($doc.getURL('view', 'xpage=wml'))
43 +{{/code}}
44 +
45 +* Send to the same page but using a xml representation and without applying the skin
46 +
47 +{{code language="none"}}
48 +$response.sendRedirect($doc.getURL('view', 'xpage=xml'))
49 +{{/code}}
50 +
51 +* Send to a page to get a RSS Feed //(need further explanation)//
52 +
53 +{{code language="none"}}
54 +$response.sendRedirect($xwiki.getURL('Some.Document', 'view', 'xpage=rdf'))
55 +{{/code}}
56 +
57 +=== XWiki 2.0 Syntax ===
58 +
59 +Don't forget to embrace the snippet between Velocity tags when you work in XWiki 2.0 syntax.
60 +
61 +{{code language="none"}}
62 +{{velocity}}
63 +$response.sendRedirect($xwiki.getURL('Main.Home'))
64 +{{/velocity}}
65 +{{/code}}
66 +
67 +=== Removing Redirects Again ===
68 +
69 +Removing the redirect again, once added, [[can prove to be difficult if your default editor is the WYSIWYG CKeditor>>https://jira.xwiki.org/browse/XWIKI-4211]]. In this case, the macro will even be executed in edit mode, redirecting you do to the target page before you have a chance to remove or alter the redirect.
70 +
71 +So if your default editor is the WYSIWYG editor, and you want to edit a redirect on the following page:
72 +
73 +{{code language="none"}}
74 +https://xwiki.example.org/xwiki/bin/view/Main/
75 +{{/code}}
76 +
77 +You manually have to change the URL as follows:
78 +
79 +{{code language="none"}}
80 +https://xwiki.example.org/xwiki/bin/edit/Main/?editor=wiki
81 +{{/code}}
82 +
83 +This will cause the wiki text editor to open with the page's source code and the redirect can be edited or removed without any problems, even if your default editor is the WYSIWYG / CK editor.
Type
... ... @@ -1,0 +1,1 @@
1 +snippet
Only Custom Installation instructions
... ... @@ -1,0 +1,1 @@
1 +No
Summary
... ... @@ -1,0 +1,1 @@
1 +Automatically send users to the page defined between the brackets
License Name
... ... @@ -1,0 +1,1 @@
1 +GNU Lesser General Public License 2.1
license
... ... @@ -1,0 +1,1 @@
1 +LGPL
Name
... ... @@ -1,0 +1,1 @@
1 +Redirect
contributors
... ... @@ -1,0 +1,1 @@
1 +Guillaume Lerouge
Authors
... ... @@ -1,0 +1,1 @@
1 +xwiki:XWiki.GuillaumeLerouge
supported
... ... @@ -1,0 +1,1 @@
1 +0
XWiki.XWikiComments[0]
Date
... ... @@ -1,0 +1,1 @@
1 +2012-01-23 17:26:33.0
Author
... ... @@ -1,0 +1,1 @@
1 +xwiki:XWiki.gdelhumeau
Comment
... ... @@ -1,0 +1,1 @@
1 +Thx for this snippet.

null

cogAutomatically send users to the page defined between the brackets
Developed by

Guillaume Lerouge

Rating
Rate!
0 Votes
LicenseGNU Lesser General Public License 2.1

Description

Once the snippet is added to a page, if you come back to that page in "view" mode you will be automatically sent to the page defined between the brackets.

Examples

Basic Redirects

  • Send the user to an external website
$response.sendRedirect("http://www.w3.org")
  • Send the user to another page on the wiki
$response.sendRedirect($xwiki.getURL('Some.Document'))
  • Send the user to another page on the wiki, in edit mode
$response.sendRedirect($xwiki.getURL('Some.Document', 'edit'))
  • Send the user directly to the edit mode of the page viewed
$response.sendRedirect($doc.getURL('edit'))

Advanced Redirects

  • Show the same page to the user but without applying the skin
$response.sendRedirect($doc.getURL('view', 'xpage=plain'))
  • Show the same page in wiki markup language but without applying the skin
$response.sendRedirect($doc.getURL('view', 'xpage=wml'))
  • Send to the same page but using a xml representation and without applying the skin
$response.sendRedirect($doc.getURL('view', 'xpage=xml'))
  • Send to a page to get a RSS Feed (need further explanation)
$response.sendRedirect($xwiki.getURL('Some.Document', 'view', 'xpage=rdf'))

XWiki 2.0 Syntax

Don't forget to embrace the snippet between Velocity tags when you work in XWiki 2.0 syntax.

{{velocity}}
$response.sendRedirect($xwiki.getURL('Main.Home'))
{{/velocity}}

Removing Redirects Again

Removing the redirect again, once added, can prove to be difficult if your default editor is the WYSIWYG CKeditor. In this case, the macro will even be executed in edit mode, redirecting you do to the target page before you have a chance to remove or alter the redirect.

So if your default editor is the WYSIWYG editor, and you want to edit a redirect on the following page:

https://xwiki.example.org/xwiki/bin/view/Main/

You manually have to change the URL as follows:

https://xwiki.example.org/xwiki/bin/edit/Main/?editor=wiki

This will cause the wiki text editor to open with the page's source code and the redirect can be edited or removed without any problems, even if your default editor is the WYSIWYG / CK editor.

Prerequisites & Installation Instructions

Copy the code snippet to a page and save it.

Get Connected