Personal tools

Default to Exclude from Navigation

This brief article describes how to default the exclude from navigation property to True.





Although the best way to do this is within the schemata.py file on the FileSystem,

/Products/ATContentType/content/schemata.py

ATContentTypeSchema = BaseSchema.copy() + MetadataSchema((
    BooleanField('excludeFromNav',
        required = False,
 # ADD THE LINE BELOW:
        default = True,
        languageIndependent = True,


this approach doesn't work when you have multiple Plone sites running on one Zope Instance, and you wish to affect only one of the sites.

There's a quick "hack" that will default the Exclude from Navigation property to True for all new content, assuming the content is added via Portal Factory.

The script you want to edit here is:

/portal_skins/archetypes/content_edit_impl


Add the following code:

if context.absolute_url().find('portal_factory') > 0:
    new_context.setExcludeFromNav(True)
    REQUEST.set('excludeFromNav', True)



before

new_context.processForm()




Free link to your website when you post your code