collective.contemplate

Add content from existing content templates

The collective.contemplate package allows site administrators to designate content items as the template from which new items of that type will be created.

When creating content from a template, the initial edit form is rendered and validation performed on the template after changing the owner of the template to the current user within a transaction.savepoint() which is rolled back after rendering. As a result, portal_factory is not involved and indexing occurs only on the final copy of the template. This may result in performance gains though this has not been tested.

While designed to be Archetypes agnostic, only an Archetypes implementation is currently provided. Templates may currently be designated using Archetype UIDs for the global templates or references for the context specific templates.

A reserved_id property can also be set on type information objects in portal_types. If set and an object with that ID already exists in the container, then the type is not allowed to be added.

Installation

To use collective.contemplate for the Plone content types, include the collective.contemplate configure.zcml in your instance and install “Content Templates” in the “Add-on Products” control panel, or in the ZMI through portal_setup. This will replace the Plone content type information with template versions.

To install for other content types, register a template add form for the content type and use the TemplateDynamicViewTypeInfo meta_type for the content type information.

In the ZCML for the browser views:

<contemplate:formControllerPage
     name="addFoo"
     type_name="Foo"
     for="zope.app.container.interfaces.IAdding"
     permission="foo.AddFoo" />

Note that the “foo.AddFoo” permission must be registered and the name “addFoo” must be the same as your content type constructor. If you’re using Archetypes, then the constructor may auto-generated by prefixing “add” to the content class name.

In the GenericSetup profile types.xml file:

<object name="Foo" meta_type="TemplateDynamicViewTypeInfo "/>

In the GenericSetup profile types/Foo.xml file:

<?xml version="1.0"?>
<object name="Foo"
   meta_type="TemplateDynamicViewTypeInfo">

Usage

This package is currently incomplete until a UI for designating templates is included. In the mean time, you may set the global templates in the ZMI or context specific templates using the references GenericSetup import handler provided by collective.gsqi.

You can use a given content item as the global template by setting the global_uid property of the content type information under portal_types in the ZMI. Set global_uid to the Archetypes UID of the template.

You can use a content item as the template in the context of a specific folder by setting a reference from the folder to the item with the relationship of “contemplate.${type_info/getId}” where “${type_info/getId}” is the id of the content type.

A reserved id can be set using the reserved_id property of the content type information under portal_types in the ZMI.

Updated on 23 August 2009

Imported from Plone on Mar 15, 2021. The date for this update is the last modified date in Plone.

Comments

comments powered by Disqus