Search Filters
Release 1.3 - ...
Faceted Search can be initialized with a set of default filters using the Filters property. This is a JSON that contains the following settings:
Property | Type | Description |
---|---|---|
filters | object | Root property that contains all the applied filters. |
filters.<filterName> | object | All properties that belong to a single filter. The <filterName> applies to the facet name in the query xml. |
filters.<filterName>.selection | array | Contains each filter setting. |
filters.<filterName>.selection[i].key | string | The filter key, used in the WHERE clause of the database query. |
filters.<filterName>.selection[i].name | string | A friendly name, used to display the filter. |
filters.<filterName>.multi | string |
Determines how multiple keys are combined:
|
filters.<filterName>.inv | boolean | Inverts the selection. Multiple keys are always combined with or. |
filters.<filterName>.list | string |
Determines how the filters are displayed to the user:
|
The following example allows the user to search News items that were published in the last year. The News filter is visible to the user, but it can't be changed. The period filter is hidden.
Smartsite SXML | Copy Code |
---|---|
<se:buffer name="filters"> { "filters":{ "period":{ "selection":[ { "key":"365", "name":"last year" } ], "multi":"single", "list":"hide" }, "contenttype":{ "selection":[ { "key":"24", "name":"News" } ], "multi":"single", "list":"rdonly" } } } </se:buffer> {sml_facetedsearch(filters=$filters)} |