Filter Custom Module on more than 1 item

Including a custom module layout filtering the results by one of the data fields is straight forward but how would I go about listing items based on filtering of say 2 field items? It seems as though I can only insert a single filterBy parameter in the component.

1 Like

Hi @TopLeftDesigns
Yes, filtering can only be done by one field (directly via the component filterBy parameter).

For multiple fields you can perhaps use the searchScope parameter.
This basically mimics how a search form would filter results if multiple fields are used in the search.
However, this method only uses an AND operator, so the values you search on both need match for an item for it to be returned.

An example of searchScope in use for 2 fields:

{% component source: "Your Module", layout: "List", searchScope: "{'prop_CustomField1':'Your Value 1','prop_CustomField2':'Your Value2'}", type: "module" %}
1 Like

Hi Adam

Thanks for the quick response. I actually thought of that and did notice it was an AND operation but that suits my case. Using the code below, I don’t get any results filtered… the results list all items ignoring the filters

{% component source: "Offices and Suites", layout: "List", searchScope: "{'Type':'Office','Location':'Southport'}", sortBy: "Name", sortOrder: "ASC", limit: "30", type: "module" %}

Have I overlooked something?


I should note that the properties ‘Type’ and ‘Location’ are both a Checkbox List

You’ll need to add prop_ to each field/property name, so:
prop_Type and prop_Location

The checkbox type should still work I think.

For a property with multiple values (like a checkbox) the data is in an array, so you can filter multiple values within that as well, like:

1 Like

Thank you that did the job… Most appreciated.

Correctly working code is

{% component source: “Offices and Suites”, layout: “List”, displayPagination:“true”, searchScope: “{‘prop_Type’:‘Office’,‘prop_Location’:‘Southport’}”, sortBy: “Name”, sortOrder: “ASC”, limit: “30”, type: “module” %}

1 Like