Wednesday, February 6, 2008

Supplementary views in Plone

I want to provide several views for certain content types for content loaders to choose from in our project. The suppl_views attribute in the archetype is the place to define these alternate views. So in your content type you have this:

suppl_views = ('my_alternate_view',)

When the content loader goes to modify that particular content via the Plone front end, they could choose 'my_alternate_view' as one of the items under the display tab.

If you want to get fancy you can get this information in code as well:

MyType.suppl_views # returns the supplement views.
fti = MyType.getTypeInfo() # gets Factory Type Info on the portal type
fti.getAvailableViewMethods(MyType) # Lists all the views for a type with the default one first.

Very handy and works in both Plone 2.5x and Plone 3.0x.

No comments: