You are here: Home / Documentation / How To's / How to add an item to the add new menu

How to add an item to the add new menu

by ledwell published Oct 07, 2011 03:54 PM, last modified Aug 16, 2016 10:49 AM
Add an item like a ploneformgen form to the "add new" menu

This tutorial essentially puts in a redirect link in the "add new menu". The redirect can go to any type of plone object like a page or image or form.

Why?

You would do something like this if you had created a ploneformgen form with a saveDataAdapter that was used to add content to the site. For example I might have a form that makes it easy for my content editors to add data like ... awards or classrooms or points of pride type of information.

You will need to have permissions to access the ZMI

Create a PloneFormGen Form

You'll need to have something for the new "add new" item to go to. So create a form or a page and know the name. For this example well assume the object were trying to link to is called "pointOfPride"

Create a New View

I copied the existing news_view for myself.

  • Login
  • Browse to the ZMI
  • Navigate to "portal_skins" - "plone_content"
  • Select the "newsitem_view"
  • Choose "Customize" (this should place this view in the Custom Folder)

Change the Name of the view

  • In the breadcrumb Trail choose "Custom"
  • Choose the checkbox next to the item "newsitem_view"
  • Choose "rename"
  • Rename it to "pointOfPride_view"

Edit the existing views code

  • Choose the "pointOfPride_view" text so your editing the code.
  • Highlight everything there and replace it with the following (note the redirect code code at the bottom should be the same as the object your trying to redirect to;
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
      xmlns:tal="http://xml.zope.org/namespaces/tal"
      xmlns:metal="http://xml.zope.org/namespaces/metal"
      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
      lang="en"
      metal:use-macro="context/main_template/macros/master"
      i18n:domain="plone">
<body>

## 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()+'/pointOfPride')

</body>
</html>
  • Choose "Save Changes"
  • Your now done here

Create a new Content Type

  • Browse to "portal types" in the ZMI
  • Choose the checkbox for the "news item" content type
  • Choose "Copy"
  • Choose "Paste"
  • Choose the check box for copied news content type
  • Choose "rename"
  • Give it a name like "pointOfPride"
  • Choose the Content Type now named "pointOfPride
  • Change the name to what ever you want to see in the "add new" drop down
  • Change the initial view name to " pointOfPride_view " (no quotes)
  • Change the Default View Method to " pointOfPride_view " (no Quotes
  • Change the "Available view methods" to " pointOfPride_view " (no Quotes)
  • Choose Save

You should now have a drop now item that redirects to a page or a form

Add Icon to new item in Add New Menu

  • Create your icon, Should be 16X16, I named mine "pointOfPrideIcon.png"
  • Save the image into your "Custom" folder
  • Open the PointOfPride Content type
  • add the following to the "Icon (Expression"
string:${portal_url}/pointOfPrideIcon.png
Navigation