Skip to main content

Plone addon for filtering collection results.

Project description


Faceted navigation filter for collection results.

This Plone 5 addon allows you to filter collections results for additional catalog metadata. For example, you can add a subject filter, but also a filter for authors or portal types. This can also be used to build tag clouds.

The filter types can be extended (see: collective.collectionfilter.vocabularies).

Besides the “Collection Filter” portlet/tile there is also a “Collection Search” portlet/tile for doing a fulltext search on the collection results.

Overloading GroupByCriteria

collective.collectionfilter.vocabularies.GroupByCriteria is a singleton, registered as global utility and used to provide a list of possible indices, which grouped values will provide your filter criteria.

It uses a data structure like this:

self._groupby = {
    it: {                   # Index name
        'index': it,             # Name of the index to use
        'metadata': it,          # Name of the metadata column to use
        'display_modifier': _ ,  # Function to prepare the metadata column value for displaying
        'index_modifier': None,  # Function to transform the index search value.
        'value_blacklist': [],   # Blacklist of index values, which should not included in the filter selection. Can be a callable.
        'sort_key_function': lambda it: it['title'].lower(),  # sort key function. defaults to a lower-cased title
    for it in metadata

As you can see, the standard GroupByCriteriaVocabulary implementation implies, that the index name is the same as the metadata column name. Also, we use the collective.collectionfilter message catalog as standard display_modifier (you can register translations under the collective.collectionfilter domain to translate index values).

If you need a special display_modifier, or index or metadata columns do not have the same identifier, you can modify this data structure. For that, register an adapter for IGroupByModifier, which adapts to the GroupByCriteria utility. Within this adapter, you can modify the already populated _groupby attribute (do not use the groupby, which is a property method and at this point hasn’t finished).

This is how.

Write an adapter:

# -*- coding: utf-8 -*-
from collective.collectionfilter.interfaces import IGroupByCriteria
from collective.collectionfilter.interfaces import IGroupByModifier
from zope.component import adapter
from zope.interface import implementer

sort_map = {
    'VALUE1': 3,
    'VALUE2': 1,
    'VALUE3': 2,

def subjectsort(it):
    # Sorts the value after a fixed sort map
    val = it['title']
    return sort_map.get(val, 0)

def groupby_modifier(groupby):
    groupby._groupby['Subject']['display_modifier'] = lambda x: x.upper()
    groupby._groupby['Subject']['sort_key_function'] = subjectsort
    groupby._groupby['my_new_index'] = {
        'index': 'my_new_index',
        'metadata': 'my_new_index_metadata_colum',
        'display_modifier': lambda it: u'this is awesome: {0}'.format(it)

Register the adapter:

<configure xmlns="">
  <adapter factory=".collectionfilter.groupby_modifier" name="modifier_1" />


Your adapter is called by collective.collectionfilter.vocabularies.GroupByCriteria.groupby.


This package is compatible with Plone 5 and above. Note that in 5.0 some functionality is reduced such as AJAX loading of search results.


  • Johannes Raggam

  • Peter Holzer

This package is based on collective.portlet.collectionfilter and collective.portlet.collectionbysubject.


2.0.1 (2018-12-13)

  • Fix upgrade steps and reapply profile to fix bundle registration Remove conditional reinitialization - caused problems with other patterns [agitator]

2.0 (2018-12-08)

Breaking changes:

  • Remove the cache_time setting and replace it with cache_enabled.

  • changed view attribute header_title to title.

  • Depend on All target collections must provide interface. The result method will be callend on this behavior adapter.

  • There is a implicit dependency to Font Awesome for the filter tile edit links. That has to be revisited to make it work out of the box.

  • Modernized markup for easier styling


  • Optimize the cache key by including the current language, user roles instead of id and the database counter.

  • Remove the view_name part when populating the browser history with filter changes. The view_name part is for loading specific AJAX tiles, but should probably not be displayed.

  • Add filter and search tiles.

  • Add a sort_key_function key to the IQueryModifier dict to allow for a different sort key function when sorting the values.

  • Add a index_modifier key to the IQueryModifier indexes dict to allow transforming of index search values. For KeywordIndex indices the index_modifier is automatically set to encode the value to utf-8.

  • Add a value_blacklist key to the IQueryModifier indexes dict to allow blacklisting of individual index values.

  • Add view_name configuration parameter to call a special result listing view. This can be used to call a tile instead to call the whole context view.

  • Add content_selector configuration parameter to choose a DOM node from the source to inject into the target.

  • Ensure early exit on the content filter traverse handler if it is not needed to run.

  • Make backwards compatible with Plone 5.0 [nngu6036, instification]

Bug fixes:

  • When reloading the collection in JavaScript, use the content selector’s parent as base to trigger events on. The content selector itself is replaced and events cannot be catched.

  • Register the bundle compile files as collectionfilter-bundle-compiled.js and collectionfilter-bundle-compiled.css, so that using plone-compile-resources results in the same files. See:

  • Sort the filter value list for filter title instead filter value.

  • fix collectionsearch portlet [petschki]

  • when providing a custom IGroupByCriteria adapter, fallback to title sorted values if no sort_key_function is given. [petschki]

1.0.1 (2018-02-09)

  • Fix target collection selection via catalog vocabular and RelatedItemsFieldWidget. [agitator]

1.0 (2018-01-27)

  • Implement AJAX search for the collection search portlet. [thet]

  • Update the history / location bar URL with the current filter URL. [thet]

  • Fix error where closest DOM method isn’t supported on IE. Fixes #6. [agitator]

  • Register bundle to depend on * to avoid weird Select2 initialization error. [thet]

  • Add input_type option to be able to better select the type of input. Add input_type support for dropdowns. Remove as_input attribute and provide upgrade step for it. [thet]

  • Initial release from collective.portlet.collectionfilter. [thet]

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

collective.collectionfilter-2.0.1.tar.gz (41.3 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page