Redirect to the first subnavigation entry
Purpose
Sometimes, customers want the site navigation to procede automaticly to the first entry (i.e. Folder) of the subnavigation. Normaly you could do this by adding a Page Template "index_html" in the ZMI (Zope Management Interface) with a redirect to the first subfolder (context.REQUEST.response.redirect(...)). But normal plone editor cannot handle ZMI page templates.
This how-to describes a simple redirect procedure that can also be used by a plone content contributer/editor.
Prerequisities
This is an adhoc customization in the ZMI. You only need to have a manager role so that you can customize plone skins in the portal_skins/custom folder.Step by step
This are the steps you need to do:
- In the ZMI you have to create a python script "redirect_to_first_entry" and give it a readable title like 'Go to first element of the subnavigation'.
- In portal_types/Folder add "redirect_to_first_entry" a view method in "Available view methods"
1. Creating the redirect python script
In the ZMI create a script (Python) "redirect_to_first_entry" in your portal_skins/custom folder:
folder_contents = context.getFolderContents() for fc in folder_contents: if fc.portal_type == 'Folder' and not fc.exclude_from_nav : context.REQUEST.response.redirect(fc.getObject().absolute_url()) break # yes, you have to! return ''
Enter a human readable Title like "Go to first element of the subnavigation". Then change the Proxy Roles of the script to "Manager".
2. Add a view method to the Folder content type
In the ZMI go to the portal_types/Folder and add "redirect_to_first_entry" a view method in "Available view methods":

In Plone, the editors/contributors will see a new view action that allows them to redirect the user to the first entry of the subnavigation:

That's all. Hope it's useful. Feel free to comment this How-to.

Author: