Wednesday, September 8, 2010

Adding a list of items to a content type without CompoundField

With all the Plone 4 goodness that surrounds us, you'd almost forget that there still are Plone 3 sites which need attention and extra features.

Our client wanted "be able to add a list of images to item X", for display in a slideshow on the item's view. I first thought of the CompoundField add-on for Archetypes content, which I'd used before. But because of technical difficulties with the current Archetypes release, I went looking for another way.

I found it in Plone's Collections feature: We add a reference to a Collection (code below), and let editors decide what images they want to show there. Advantages:
* It's easier to change a lot of images
* It allows for re-use of images
* It allows for dynamic content (if you add a criterion for a certain tag, for example, all new content with that tag will be "on item X" as well)
* Last but not least: It's a well-known, well supported Plone feature.

The last point is important: This approach fits the philosophy of letting standard Plone functionality take care of things, avoiding custom content as much as possible, or keeping them as minimal as possible when you do use them.

There might also be a disadvantage: it's less intuitive. But everybody should know about Collections, they're central to Plone and they can help you (and your customer) in many ways.

custom_content_type_schema = Schema ((
label="Extra images for slideshow",
description="Point to a Collection that contains Images",

1 comment:

Fred said...

collective.carousel is using the same method (reference a collection) to attach a list of items to an object so it can display the carousel.