Attention

This document was written for an old version of Plone, Plone 3, and was last updated 902 days ago.

To learn how to upgrade to the current version of Plone, read the upgrade manual.

Create a main navigation link which redirects to an arbitrary location AND maintain control of the portal_tab order

by Charles O'Brien last modified Dec 03, 2009 03:43 AM
You want to have a link in your main navigation that redirects to a specific url and you want to control the order of how the tabs are displayed.

Purpose

If a link is added using portal_actions this link would be displayed in the navigation before content items such as the News and the Events Folders.  Another way to approach this problem would be to add a Link to the site root, but this would require two clicks to travel to the destination page.  This How-to explains one way to have a link displayed in portal_tabs which opens immediately and is order-able.

2 Use Cases as Examples:

  1. A link to contact-info which is nested between News and Events
  2. A link to an external url which is nested between News and Events

Step By step

  1. Create a folder in the root of the Plone site.  The Title will be the name of the link such as 'Contact'.
  2. Now open the ZMI add a DTML Document to the folder you just created.
  3. Give the DTML Document an id and a Title, and choose 'Save and Edit'.
  4. Paste in this code, and tweak as needed, to create the DTML redirect for an internal link:
<dtml-var standard_html_header>
<dtml-let target="portal_url() + 'contact-info'">
<h1><a
href="<dtml-var target>"><dtml-var target></a>.</h1>
<dtml-call expr="RESPONSE.redirect(target)">
</dtml-let>
<dtml-var standard_html_footer>

For an external link use code like this:

<dtml-var standard_html_header>
<dtml-let target="'http://www.google.com'">
<h1><a
href="<dtml-var target>"><dtml-var target></a>.</h1>
<dtml-call expr="RESPONSE.redirect(target)">
</dtml-let>
<dtml-var standard_html_footer>

 

  1. Now, in the ZMI go to the 'Properties' tab of the folder containing the DTML Document.
  2. Add a new property with the 'Name' of default_page and the 'Type' of string and the 'Value' of the id for the DTML Document.

The link should now work!

Optional:  Prevent the view of this folder from ever being able to be changed


1.  In the ZMI go to the Security tab of the new folder that was created.
2.  Uncheck 'Acquire permission settings' for the permission  'Modify view template'  and make sure no checkboxes are checked for this permission.


Further information

There are a handful of ways that this can be accomplished.  It would be interesting to see how others have approached this problem.


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.