Project Awesome project awesome

collective.collectionfilter

Faceted navigation filter for collection or contentlisting tiles.

Package 9 stars GitHub

collective.collectionfilter

CI Meta

Faceted navigation filter for collection or contentlisting tiles.

Filter listing results for any catalog-indexed field — subjects, authors, portal types, and more. The available filter types can be extended (see collective.collectionfilter.vocabularies).

There are five portlets/tiles available:

  • Collection Filter — filter by values (select, radio, checkbox, link)
  • Collection Search — fulltext search (SearchableText) on collection results
  • Collection Maps — a LeafletJS map that shows and filters IGeolocatable items (requires collective.geolocationbehavior, see below)
  • Collection Result Listing Sort — let users sort the filtered results
  • Collection Filter Reset — reset all active filters

Filtering collections

Add filter/search portlets directly to a collection. Selecting filter values reloads results without a page refresh via AJAX.

If your theme or view template needs customization for AJAX loading, adjust the Content Selector and/or View Template settings. The selector must exist on both the source collection template and the target page.

Filters can also target a remote collection — specify a target collection in the portlet/tile settings. If AJAX is disabled, selecting a filter option redirects to the collection.

Mosaic integration

Install the extra:

pip install collective.collectionfilter[mosaic]

Add filter tiles via the Mosaic Insert menu and assign a collection. Use a Content Listing tile to display results.

Multiple content listings and filters can coexist on the same page — use unique CSS classes in the listing tile settings and reference them in the filter tile's Content Selector.

Geolocation support

Install the extra:

pip install collective.collectionfilter[geolocation]

Enables a LeafletJS map tile/portlet that displays IGeolocatable collection items. Enable Narrow down results to filter the collection and other tiles when the user pans or zooms the map.

Customizing GroupByCriteria

GroupByCriteria is a global utility that defines which catalog indexes are available as filter criteria.

Each index entry has this structure:

{
    'index': 'Subject',              # catalog index name
    'metadata': 'Subject',           # metadata column name
    'display_modifier': _,           # callable(value, index) -> display string
    'index_modifier': None,          # callable to transform search values
    'value_blacklist': [],           # values to exclude (list or callable)
    'sort_key_function': lambda it: it['title'].lower(),
}

To customize, register an IGroupByModifier adapter:

from collective.collectionfilter.interfaces import IGroupByCriteria
from collective.collectionfilter.interfaces import IGroupByModifier
from zope.component import adapter
from zope.interface import implementer


@implementer(IGroupByModifier)
@adapter(IGroupByCriteria)
def groupby_modifier(groupby):
    groupby._groupby['Subject']['display_modifier'] = lambda x, idx: x.upper()
    groupby._groupby['my_custom_index'] = {
        'index': 'my_custom_index',
        'metadata': 'my_custom_metadata',
        'display_modifier': lambda val, idx: f'Custom: {val}',
    }
<configure xmlns="http://namespaces.zope.org/zope">
  <adapter factory=".mymodule.groupby_modifier" name="my_modifier" />
</configure>

The adapter is called by GroupByCriteria.groupby. Modify the _groupby dict (not the groupby property, which triggers adapter lookup).

Compatibility

  • Version 6.x — Plone 6.2+
  • Version 5.x — Plone 6.0+
  • Version 4.x — Plone 5.2
  • Version 3.x — Plone 5.0/5.1

Should AJAX loading not work with your theme, disable it in the registry or override via diazo.

Authors

  • Johannes Raggam
  • Peter Holzer

Based on collective.portlet.collectionfilter and collective.portlet.collectionbysubject.

Back to Plone