plone.app.contenttypes

Default content types for Plone based on Dexterity


Keywords
plone, content, types, dexterity
License
GPL-2.0+
Install
pip install plone.app.contenttypes==1.4.12

Documentation

https://api.travis-ci.org/plone/plone.app.contenttypes.png?branch=master

plone.app.contenttypes provides default content types for Plone based on Dexterity.

It contains the following types:

  • Collection
  • Document
  • Event
  • File
  • Folder
  • Image
  • Link
  • News Item

These types are editable and extendable through-the-web and you can add or remove fields and behaviors using the control-panel "Dexterity Content Types" (/@@dexterity-types).

This package is included in Plone 6 and does not need installation.

Schemata that are defined in XML-files using plone.supermodel allow editing those types' schemata through the web. This is the case for the default File, Image and Link content types. Schemata coming from behaviors, on the other hand, are not editable through the web. The Document, News Item, Folder and Event default types, for example, have no schemata of their own at all, all their fields are provided by behaviors.

You have several options:

  1. Extend the types through-the-web by adding new fields or behaviors in the types-controlpanel /@@dexterity-types.

  2. Extend the types with a custom type-profile that extends the existing profile with behaviors, or fields.

    You will first have to add the type to your [yourpackage]/profiles/default/types.xml.

    <?xml version="1.0"?>
    <object name="portal_types" meta_type="Plone Types Tool">
      <object name="Folder" meta_type="Dexterity FTI" />
    </object>

    Here is an example that enables the image-behavior for Folders in [yourpackage]/profiles/default/types/Folder.xml:

    <?xml version="1.0"?>
    <object name="Folder" meta_type="Dexterity FTI">
     <property name="behaviors" purge="False">
      <element value="plone.app.contenttypes.behaviors.leadimage.ILeadImage"/>
     </property>
    </object>

    By adding a schema-definition to the profile you can add fields.

    <?xml version="1.0"?>
    <object name="Folder" meta_type="Dexterity FTI">
     <property name="model_file">your.package.content:folder.xml</property>
     <property name="behaviors" purge="False">
      <element value="plone.app.contenttypes.behaviors.leadimage.ILeadImage"/>
     </property>
    </object>

    Put the schema-xml in your/package/content/folder.xml (the folder content needs a __init__.py)

    <model xmlns:security="http://namespaces.plone.org/supermodel/security"
           xmlns:marshal="http://namespaces.plone.org/supermodel/marshal"
           xmlns:form="http://namespaces.plone.org/supermodel/form"
           xmlns="http://namespaces.plone.org/supermodel/schema">
      <schema>
        <field name="teaser_title" type="zope.schema.TextLine">
          <description/>
          <required>False</required>
          <title>Teaser title</title>
        </field>
        <field name="teaser_subtitle" type="zope.schema.Text">
          <description/>
          <required>False</required>
          <title>Teaser subtitle</title>
        </field>
        <field name="teaser_details" type="plone.app.textfield.RichText">
          <description/>
          <required>False</required>
          <title>Teaser details</title>
        </field>
      </schema>
    </model>

You could alternatively override the property model_file of the type-definition with a empty string and use the property schema to provide your custom python-schema.

For more complex features you should always consider create custom behaviors and/or write your own content-types since that will most likely give you more flexibility and less problem when you want to upgrade to a newer version in the future.

For more information on custom dexterity-types and custom behaviors please read the dexterity documentation.

If you changed the base-class of existing types (e.g. because you changed them to be folderish) you also need to upgrade the base-class of existing objects. You can use the following form for this: @@base_class_migrator_form.

This form lets you select classes to be updated and shows the number of objects for each class. This form can be used to change the base-class of any dexterity-types instances. The migration will also transform itemish content to folderish content if the new class is folderish. You might want to use the method plone.app.contenttypes.migration.dxmigration.migrate_base_class_to_new_class in your own upgrade-steps.

Contributors please read the document Process for Plone core's development

Sources are at the Plone code repository hosted at Github.

GNU General Public License, version 2