Accueil / Blog / Métier / Archives / Configuration of browser view

Configuration of browser view

Par Jean-Michel François — publié 27/06/2011

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 !

ABONNEZ-VOUS À LA NEWSLETTER !
Voir aussi
PloneConf 2016, un vent nouveau sur Plone PloneConf 2016, un vent nouveau sur Plone 02/11/2016

Résumé de la conférence annuelle sur Plone qui s'est tenue à Boston.

Turning hackability into a use case 27/01/2015

When a CMS does not allow happy hacking anymore, it loses a very valid use case.

collective.z3cform.norobots: a captcha based on questions and answers 15/01/2010

I have released a new captcha widget/field for z3c.form in Plone. Unlike other captcha fields that ...

Plone Unified Installer and ZcxOracleDA 02/12/2010

Trying to setup cx_Oracle and ZcxOracleDA on a Plone/Zope Zeo setup using the Unified Installer ...

Connecting to Oracle with SQLAchemy and very simple Plone integration 11/06/2009

SQLAlchemy (The Python SQL Toolkit and Object Relational Mapper) allow Oracle connection through ...