Elven Magic

Forging mythic items from Plone together

Creating custom views with collective.listingviews

collective.listingviews is a real gem, if only you knew how to use it.

Next I’ll demonstrate it by creating a simple image listing view with image previews and their dimensions. The resulting listing view is simple, but can be enhanced with CSS later:

../../../_images/collective-listingviews-image-listing.png

So, let’s begin.

Once we have managed to install the add-on with buildout and restart our site, we should be able to activate the add-on through Add-ons-panel in Site Setup:

../../../_images/collective-listingviews-activated.png

Activating collective.listingviews adds two new configuration panels into Site Setup:

../../../_images/collective-listingviews-configlets-01.png

Visiting the first one (Listing Custom Fields) allows us to expose custom properties from custom content types or define new ways to display existing properties from the default content types.

../../../_images/collective-listingviews-configlets-02.png

Let’s start by clicking Add to add a new custom field display definition:

../../../_images/collective-listingviews-custom-field-01.png

Then let’s fill the fields properly for displaying dimensions from an image and finish the definition by clicking Save.

../../../_images/collective-listingviews-custom-field-02.png

Read more about using TAL-statements (TAL-expressions) from Plone Developer Manual.

Then let’s repeat this by adding a one more field for displaying a thumbnail preview of the image:

../../../_images/collective-listingviews-custom-field-03.png

Once the required custom display fields are defined, we are ready for defining a new listing view by opening Listing View -configlet from Site Setup:

../../../_images/collective-listingviews-configlets-03.png

Adding a new listing view is pretty straightforward:

../../../_images/collective-listingviews-add-view.png

Finally, we can go to a folder with images, open its Display-menu and select our brand new view to show the folder contents:

../../../_images/collective-listingviews-select-view.png

And enjoy our brand new view:

../../../_images/collective-listingviews-image-listing.png

Jus great, isn’t it!

Disclaimer

With great power comes great responsibility. It’s extremely easy to create views that break when they are trying to render unexpected content types. If you want to play it safe, use custom listing views only with collections, which allow you to limit the view see only selected content types.