Value from/to for two date fields
The “Value from/to for two date fields” filter rule (package filter_range) filters
items based on a date range defined by two separate date attributes. The first date
attribute contains the start date (“from”), the second the end date (“to”). An item is
included in the result when a given search date lies within the period defined by both
attribute values.
Typical use cases: Event periods, booking periods, validity periods with separate date attributes.
A dedicated template mm_filteritem_datepicker.html5 is available for browser-based
date input. For the HTML5 date input field, the date must be passed in the format
YYYY-MM-DD —
more information.
See also
For numeric two-field comparisons, the filter rule Value from/to for two fields is available.
Installation
The filter rule is installed via the Contao Manager or Composer:
composer require metamodels/filter_range
Settings when Creating the Filter Rule
Setting |
Description |
|---|---|
Type |
Selection of the filter rule type — here: “Value from/to for two date fields”. |
Enabled |
Enables or disables this filter rule. |
Comment |
Free text field for describing the purpose of this filter rule. |
Attribute (from) |
The first date attribute that contains the start date. |
Attribute 2 (to) |
The second date attribute that contains the end date. |
Settings for the Frontend Widget
Setting |
Description |
|---|---|
URL parameter |
The key of the URL parameter for passing the filter value. Without input,
the column name of the attribute is used. With |
URL type for the parameter |
Defines whether the parameter is passed as a slug (friendly URL) or as a GET parameter (from MM 2.4) — see SEO |
Date format |
The format in which the date is expected (e.g. |
Time type |
Defines whether only the date ( |
Label |
Label of the filter widget. |
Hide label at filter widget |
Suppresses the output of the label. |
Template |
Template for the widget output. For date picker input: |
Placeholder |
Placeholder text in the input fields. |
Filter range type |
Defines how the search date range is compared with the attribute values (s1–s5, analogous to the filter rule Value from/to for two fields). |
Greater-than-or-equal (≥) |
The “from” search date is compared inclusively ( |
Less-than-or-equal (≤) |
The “to” search date is compared inclusively ( |
Show from field |
Enables the display of the “from” date field in the widget. |
Show to field |
Enables the display of the “to” date field in the widget. |
CSS ID/class |
Sets a CSS ID or class on the widget element. |
Matching Attributes
The “Value from/to for two date fields” filter rule is suitable for the Timestamp attribute. If the filtering should be for date values only, the “Date and time handling” option in the attribute should be set to “Store date only without time”.