Introduction

by Martin Aspeli last modified Sep 17, 2009 01:23 PM
Introducing RichDocument and the contents of this tutorial

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.

**NOTE:** This tutorial refers to "version 2.0 of RichDocument":/products/richdocument/releases/2.0. This version works with Plone 2.1 and 2.5. Version 3.0 works with Plone 3, but the tutorial has not been updated to reflect the changes in the code base. It should still be useful, though. The main changes are that installation is now done using GenericSetup instead of the 'Install.py' file, and that the attachment content types and widgets have been factored out into a separate product, called 'SimpleAttachment'. The content types also contain less FTI setup information in class variables, because this is handled by the GenericSetup XML files.

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

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":/products/richdocument or from the "Collective subversion repository":https://svn.plone.org/svn/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.