You are here: Home News Configuration of browser view

Configuration of browser view

by Jean-Michel FRANCOIS last modified Jun 29, 2011 08:12 PM
I have created this add-on to make it easy to store configuration for browser view components.
Configuration of browser view

collective.configviews

Have you ever want to configure your view because each context can be displayed with some specific behaviors ? How do you have proceed ?

Let me show you many ways to achieve this:

Create a content type

For example you want to create a great slideshow. A slideshow should be just a view over images or news items with a way to configure delays, sizes, ...

This is working but you need a content type and I don't want to create new content type just to display stuff in some other ways.

(Updated on 2011-06-29: never took past example without checking if it is still true, sorry Nathan)

Store in the portal_properties / plone.app.registry

Those are working for site wide configuration and we are trying to make it context related. But you are on the way and this is great to configure default view behavior site wide ! Don't forget this.

Store the configuration in annotation

Great you get it ! Store your configuration on annotation, this is the only way to not touch your content type and attach data to it every where your view can be used.

So you will need to manage accessors, create an add/edit form for your settings, may be create a json version to let your javascript access to the configuration. This can be done with plone.autoform in a quite easy but you have to learn how to manage annotation, and you know you have at least one or two hours of work ... or may be you will ...

Use collective.configviews

This add-on let you just create a settings schema and make your view inherits from a base class and voila ! You have all the benefits we have seen in two previous solutions and even more ! If the data are schema defaults they are not stored. I let you check this add-on and give me feedback about it, it is in alpha stage:

pypi page or plone page

As an example I have done a useful add-on to let you use the Google docs viewer in Plone: collective.googledocsviewer. I will now be able to finish my first & favorite add-on: collective.gallery !

Share |
Filed under:
comments powered by Disqus