We've just added two new kind of facets in CubicWeb :
- The RangeFacet which displays a slider using jquery to choose a lower bound and an upper bound. The RangeWidget works with either numerical values or date values
- The HasRelationFacet which displays a simple checkbox and lets you refine your selection in order to get only entities that actually use this relation.
Here's an example of code that defines a facet to filter musical works according to their composition date:
class CompositionDateFacet(DateRangeFacet): # 1. make sure this facet is displayed only on Track selection __select__ = DateRangeFacet.__select__ & implements('Track') # 2. give the facet an id (required by CubicWeb) id = 'compdate-facet' # 3. specify the attribute name that actually stores the date in the DB rtype = 'composition_date'
And that's it, on each page displaying tracks, you'll be able to filter them according to their composition date with a jquery slider.
All this, brought by CubicWeb (in the next 3.3 version)