Current

This document is valid for the current version of Plone.

Redirect to a url or default view

by Charles Witt last modified Apr 28, 2011 07:54 PM
How to do it.

Purpose

If all you want is a default page to be shown when in a particular folder, then select:

Display

Select a default item as default view

A subfolder or nested object 2 or more levels down can also be selected this way.  You just need to add the "Folder" type to the default_page_types property in portal_properties/site_properties in ZMI or with GenericSetup. You can put any content type in the default_page_types.  You can actually have whole chains of default folders, which actually may cause some confusion.  If the behavior is not what you want, then perhaps you want a redirect using the following method which uses a python script.

Prerequisities

Plone 2.5, 3, or 4.  You of course need to have the "Manager" role for your Plone site.

Step by step

Go to:

Site Setup

ZMI

In the folder that you want a redirect to be triggered, click the dropdown:

Select type to add

Script (Python)

For Id, give a descriptive short name (no spaces), leave File blank

Click: Add and Edit

Leave blank the Title and Parameter List

Copy Paste the following into the body (replacing its contents):

## Script (Python) "redirect.py"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=Redirects to a default folder
##
container.REQUEST.RESPONSE.redirect(context.portal_url()+'/projects')

 

Replace the '/projects' part with the path to the specific url you want to redirect to.

Click Save Changes

Click the Properties tab

Change or Add the default_page property to: redirect.py

Click Save Changes

Now go view that folder in the regular Plone view to test that it redirects.

Further information

http://plone.org/search?SearchableText=redirect


Contribute

Something wrong or out of date? Anybody can edit or create a new article in the knowledge base. Simply create an account on this site, log in, and click the Edit button to contribute.