RichDocument: Creating content types the Plone 2.1 way

 This tutorial will teach you how to create content types the Plone 2.1 way, using the ATContentTypes library, by following the example of RichDocument, an extension of Plone's standard Page/Document type.

RichDocument sports the following features over Plone's standard Page/Document
type:

o You can upload images and attachments straight "into" the document, from the
edit tab.

o It can automatically generate image thumbnails in a floating box of images that have been uploaded, or display the first image floating. Selecting which view to use is done using Plone 2.1's new 'display' menu, and it is easy to register additional 'view methods' for selection from the 'display' menu.

At the same time, RichDocument is a drop-in replacement for the standard Page/Document type. In particular:

o It is containerish (to support uploading of images and attachments), but it behaves like a non-containerish object in that:

 o It does not get a 'contents' tab
 
 o Navigating to a RichDocument from the parent folder's 'contents' tab takes you to the document view, not a folder contents listing
 
 o It displays the 'add to folder' menu, allowing the user to add sibling objects, not an 'add item' menu for adding images and files.
 
o It has every method and attribute of the standard Page/Document type. That is, it can be used as a drop-in replacement wherever a Page is expected.
 
About this tutorial
 
  This tutorial will demonstrate how RichDocument was created. The next three parts will give an overview of the RichDocument source code and the standard techniques for creating Plone 2.1 content types. The remaining parts will cover advanced concepts in more detail.

In particular, you will learn how to:

o Correctly extend an ATContentTypes type (ATDocument in this case) and ensure the content schema, actions and aliases follow Plone 2.1 conventions

o Get title-to-id renaming for free

o Get multilingual content support via LinguaPlone

o Use the 'INonStructuralFolder' interface to signal that even though the type is technically containerish, it is not to be treated as such by the Plone UI

o Register templates with the 'display' menu

o Use standardised, catalog-based folder listings

o Use the Python Imaging Library (PIL) to create on-the-fly thumbnails of images

o Use automatic JavaScript hooks to create collapsible field-sets

o Register a style sheet with the new 'portal_css' tool from ResourceRegistries

o Prevent certain content types from showing up in standard searches

o Register new types so that they will show up in kupu's drawers

o Write basic unit tests

The examples in this tutorial all refer to RichDocument's source code. The latest release of RichDocument can be downloaded from "http://plone.org/products/richdocument":http://plone.org/products/richdocument or from the "Collective subversion repository":http://svn.plone.org/collective/RichDocument/trunk. The source code contains comments to explain what is going on. It is probably best if you download the source code and take a look at it to follow this tutorial.