Restrict the content types in the 'add item' menu
The 'add item' menu shows the content types that the current user can add to the current folder. You can configure what types show up in this menu in different ways:
- Per folder configuration
- Permissions
- portal_types
- getNotAddableTypes.py
In addition to these mechanisms, there may be builtin constraints in certain folderish content types. For example, in a Ploneboard you can only add a forum.
You cannot currently control the order of the content types in the 'add item' menu.
1. Per folder configuration
You can restrict the list of types in the 'add item' menu per folder.
You can use this, for example, to organize the content in your site and
designate a folder for specific content types (e.g. a news folder with
only news items, or an images folder with only images).
In any regular Plone folder except the portal root:
- click on "add to folder" (or "add item" if you’re in the contents tab)
- click "restrict"
- under "Mode" choose "Select manually"
- under "Addable types", select the content types that will be addable
- under "Prefered types", select the content types that are to be "favored"
This feature removes content types from the 'add item' menu in a
particular folder (and in descendant folders inheriting this setting),
and it prohibits the user from adding items of those types (e.g. by
constructing the url of the createObject page).
This feature may or may not be available in folderish content types other than regular Plone folders.
2. Permissions
Many content types have an accompanying permission 'Add type'. For example, the permission to add a news item is 'ATContentTypes: Add News Item'. The 'add item' menu presents only content types the user is allowed to add.
You can use permisions, roles and user groups to configure who can add what content types to your site. Refer to "Understanding permissions and security" for more information.
3. portal_types
In portal_types of your Plone instance in the ZMI, every content type has a checkbox 'Implicitly addable'. When it's checked, the content type can be added anywhere where the current user has the required permission. Otherwise it can only be added to folderish types that explicitly allow the type to be added.
For example, to allow news items in only one particular "news" folder of your site:
- Select News Item and uncheck "Implicitly Addable?" This removes News Item from the "add item" menu throughout your entire Plone site.
- Copy the existing type "Folder" and create a new type by renaming this copy to "News Folder".
- In your new content type “News Folder” check "Filter content types?" and under "Allowed content types" only select "News Item". This will only allow News Items to be added to your new content type folder.
- Go to your Plone site and create your new "news" folder by selecting "News Folder" from the "add item" menu.
- Go back to the ZMI in portal_types and uncheck "Implicitly addable" for your content type "News Folder" so that no more news folders can be added.
4. getNotAddableTypes.py
You can customize the Python script getNotAddableTypes.py to exclude certain content types based on context, the current user or other dynamic criteria.
The script is located in CMFPlone/skins/plone_scripts of the Plone distribution. It returns a sequence of type names that will be excluded.
For example, to remove PloneCollectorNG (or: 'pcng tracker') from the 'add item' menu of non-managers, customize getNotAddableTypes.py as follows:
# 'Favorite' is excluded by default in Plone 2.1.3
notAddableTypes = ['Favorite']
member = context.portal_membership.getAuthenticatedMember()
if not member or not member.has_role('Manager'):
notAddableTypes.append('PloneCollectorNG')
return notAddableTypes
Note that this script only removes types from the 'add item' menu, it does not prohibit the user from actually adding items of those types (e.g. by constructing the url of the createObject form). You should use permissions to control what users can and cannot do.
