Filter Sets
Note
Optionally create filter sets for backend and frontend; create filter set and activate in components or content elements/modules
Introduction
The “Filter set” component provides a comprehensive tool for influencing the view and selection of records (items) of a MetaModel. Filter sets reduce the total number of items, i.e. after filtering, a subset of these is available for output. Note that each filter set always only outputs a list of IDs (of the items), or a filter rule passes a list of IDs to the next filter rule — changing item values via an SQL query, for example, is not possible.
A filter set is created in a two-level hierarchy, where first a named filter set “as a container” is created, which in turn can contain one or more filter rules. If multiple filter rules exist at this level, they are automatically linked with AND. For an OR link, an OR filter rule must be created, which in turn can include further filter rules. With the possibilities of nesting, almost all AND/OR combinations of a native SQL query can be replicated.
Some filter rules have the selectable option to show only assigned or only remaining filter entries, to ensure a dynamic display of the filter set.
Filter sets can be used in both the backend and frontend.
Filter rules can be dynamically influenced, e.g. via GET/POST parameters, resulting in very extensive filtering.
Types of Filter Rules
Predefined item set (core):
Enter a list of IDs to filter bySimple lookup (core):
Creates a filter by an attribute; a URL parameter can be specified for filtering; with the “Static parameter” option, a value for filtering can be activated in content elements/FE modules from a select listCustom SQL (core):
Custom SQL conditions for filtering; note thehelp assistant (popup)
see also in the “Cookbook” Custom SQLAND condition (core):
Container for further filter rules with AND linkOR condition (core):
Container for further filter rules with OR link; option to execute only the first matching rule (checkbox “Stop after first match”)Checkbox status (filter_checkbox):
Checks an attribute value for 1; (formerly “Published status”); own template mm_filteritem_checkbox(.html5)Translated checkbox status (filter_checkbox):
Checks a translated attribute value for 1; (formerly “Translated published status”); own template mm_filteritem_checkbox(.html5)Yes / No (filter_checkbox):
Yes/No selection, e.g. as radio buttonsValue from/to for one field (filter_fromto):
From/to selection for values of an attribute valueValue from/to for a date field (filter_fromto):
From/to selection for date of an attribute value; own template mm_filteritem_datepicker(.html5) — Set date to YYYY-MM-DDValue from/to for two fields (filter_range):
Two fields with valuesValue from/to for two date fields (filter_range):
Two fields with values for date; own template mm_filteritem_datepicker(.html5) — Set date to YYYY-MM-DDSingle select (filter_select):
Single selection of a value, e.g. from a select list; alternatively templates mm_filteritem_radiobutton(.html5) or mm_filteritem_linklist(.html5)Multi-select (filter_tags):
Multiple selection of values, e.g. from a checkbox list; alternatively template mm_filteritem_linklist(.html5)Text filter (filter_text):
Filters by text inputPerimeter search (filter_perimetersearch):
Filters by an address/geo coordinates and a radius based on lat/long values in the records
see Perimeter SearchRegister (filter_register):
Filters by initial letters; generates a list of all or existing initial letters; own template mm_filteritem_register(.html5)Levenshtein-based search (attribute_levenshtein):
Creates a full-text index of selected attributes including similarity search and auto-completion; own template mm_filteritem_levenshtein(.html5)Filter-by-related (filter_by_related) [from MM 2.4]:
Enables filtering items with properties from a linked (relation) MetaModel; relations can be built via child table or single select
see Filter-by-related for MetaModelsLoupe (filter_loupe) [from MM 2.4]:
Creates a full-text index of selected attributes in a dedicated SQLite database — based on Loupe; more about this in the Loupe filter ruleExpression rule (filter_expression) [from MM 2.4]:
Allows the execution of further filter rules to be linked to conditions. A node is created in the rule list that can contain one or at most two further filter rules as child nodes; more about this in the Expression filter rule
Configuration Parameters
The various filter rules can be adapted to individual requirements via specific configuration options. For most filter rules, the following parameters can be set:
URL parameter: defines the keyword (key) for the URL; without specification this is the column name of the attribute. With the keyword
auto_item, the keyword is not included in the URL but only the value is output —auto_itemcan only be used for one filter rule. The keywordslanguageanditemsare reserved by Contao — from MM 2.3 these are automatically rewritten and__is appended if set as column name.URL type for the parameter: (from MM 2.4) here you can set whether the filter parameter is passed to the URL as a slug or GET parameter — more about this in the SEO tips
Template: selection of the widget template for the frontend display; in addition to the template
mm_filteritem_default, various filter rules bring their own templates such as checkbox, Levenshtein, register, etc. The templates can be customized in the usual Contao way. The surrounding template (wrapper) is selected in the CE/FE module filter.CSS ID/class: sets an ID or CSS class in the widget to be output; this allows individual control of the view/formatting.
Procedure
A new filter set is created via “
New” and a name must be assigned.
Via the icon “
Filter rules” you reach the filter rule entry list, where
a new filter rule can be set up via “
New”. Via the “clipboard icons”, the hierarchy
can be influenced during the creation of a filter rule, e.g. to insert the filter rule within
an OR rule.
Details of All Filter Rules
- Predefined Item Set
- Simple Lookup
- Custom SQL
- AND Condition
- OR Condition
- Expression Rule
- Checkbox Status
- Translated Checkbox Status
- Yes / No
- Value from/to for one field
- Value from/to for one date field
- Value from/to for two fields
- Value from/to for two date fields
- Single Select
- Multi-Select
- Text Filter
- Perimeter Search
- Register
- Levenshtein-based Search
- Filter-by-related
- Loupe
- Parent Filter