Redirect

Last modified by Gunter Ohrner on 2019/06/26 10:54

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.

Tags:
Created by Guillaume Lerouge on 2007/04/07 21:16
     

Get Connected