Last modified: May 02, 2025 By Alexander Williams

Custom Content Models in Plone

Plone is a powerful CMS built on Python. It offers flexible content types. Custom content models extend its functionality. This guide explains how to create them.

What Are Plone Content Types?

Content types define data structures in Plone. Default types include Page, News Item, and Event. Custom types solve unique content needs.

Each type has fields and behaviors. Fields store data. Behaviors add features. Together they form a content schema.

Prerequisites for Custom Content

Before starting, ensure you have:

  • A working Plone installation
  • Basic Python knowledge
  • Understanding of Plone's architecture

Need setup help? See our Plone dev environment guide.

Creating a Basic Content Type

Use Dexterity for custom types. It's Plone's modern content framework. First, create an add-on:


# In your add-on's configure.zcml
<configure xmlns="http://namespaces.zope.org/zope">
    <include package="plone.app.dexterity" />
</configure>

This enables Dexterity in your add-on. Learn more in creating Plone add-ons.

Defining Content Schemas

Schemas describe your content's fields. Use zope.schema for field definitions. Here's an example:


from zope import schema
from plone.supermodel import model

class IBook(model.Schema):
    """A book content type interface."""
    
    title = schema.TextLine(title="Title", required=True)
    author = schema.TextLine(title="Author")
    isbn = schema.TextLine(title="ISBN")
    publish_date = schema.Date(title="Publish Date")

This creates a Book type with four fields. The model.Schema base provides Plone integration.

Registering the Content Type

After defining the schema, register it:


from plone.dexterity.content import Item
from zope.interface import implementer

@implementer(IBook)
class Book(Item):
    """Book content class."""

Then add registration in ZCML:


<configure xmlns="http://namespaces.zope.org/zope">
    <plone:content
        name="book"
        schema=".interfaces.IBook"
        class=".content.Book"
        />
</configure>

Adding Behaviors

Behaviors add reusable features. Plone includes many built-in ones. For example:


from plone.autoform.interfaces import IFormFieldProvider
from zope.interface import provider

@provider(IFormFieldProvider)
class IBookWithImage(model.Schema):
    """Extend book with image behavior."""
    
    image = schema.Bytes(title="Cover Image")

Then register the behavior:


<plone:behavior
    name="book.with_image"
    title="Book with Image"
    provides=".interfaces.IBookWithImage"
    />

Creating Views for Custom Types

Views display your content. Here's a simple view:


from Products.Five import BrowserView

class BookView(BrowserView):
    """Default book view."""
    
    def __call__(self):
        return self.index()

Register it in ZCML:


<browser:page
    name="view"
    for=".interfaces.IBook"
    class=".views.BookView"
    template="templates/bookview.pt"
    permission="zope2.View"
    />

Testing Your Content Type

After creating your type, test it:


bin/instance restart

Then add content in Plone. Verify all fields work. Check behaviors function properly.

Advanced Customization

For complex needs, explore:

  • Custom add/edit forms
  • Workflow integration
  • Indexing and searching

Learn more in Plone fundamentals.

Conclusion

Custom content models extend Plone's power. Dexterity makes creation easy. Schemas define structure. Behaviors add features.

Start with simple types. Gradually add complexity. Always test thoroughly. Your content will shine.

Need Python help? See Plone for Python developers.