Skip to main content

Plone addon for filtering collection results.

Project description

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 asynchronously (no page refresh) via AJAX.

If your theme or view template needs customization for AJAX loading, adjust the Content Selector and/or View Template settings. Make sure the selector exists 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. Without AJAX, 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]

This provides a LeafletJS map tile/portlet showing 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

If AJAX loading doesn't 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.

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-6.0.0.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

collective_collectionfilter-6.0.0-py3-none-any.whl (2.1 MB view details)

Uploaded Python 3

File details

Details for the file collective_collectionfilter-6.0.0.tar.gz.

File metadata

File hashes

Hashes for collective_collectionfilter-6.0.0.tar.gz
Algorithm Hash digest
SHA256 a1f2a9bf9001e3151f1bd3a054f0e2966cb76975c22853698616f168122fba8d
MD5 4fcddea5f9f86c48cf8d73816c8913f2
BLAKE2b-256 f62d8f45fad5775e48376060c68634ecb266dd9956bc55e13ef57fc231b8b023

See more details on using hashes here.

File details

Details for the file collective_collectionfilter-6.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for collective_collectionfilter-6.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 865bf9b19b9d6cf72118245737337bf481f5de7cd196a0034c3cf4e2e9db9358
MD5 69e734342b8f96caca59311310924131
BLAKE2b-256 3a55b1561923975c61ff9c858988fc8c7906b8e7509e3b5f63b8e7c5a307de7c

See more details on using hashes here.

Supported by

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