CMS (Formerly Content Manager): About Filtering and Sorting Collection Items on Your Site

6 min read
When a dataset is connected to a collection, it has access to all of that collection's fields and items. To control which items appear in the dataset's connected elements, and the order in which they appear, add filters and sort conditions in the dataset settings

Hiding a field in your collection view in the CMS (Content Management System) does not hide the field from the dataset. Similarly, sorting or filtering items in your collection view does not sort or filter the items on your page or in your dataset.
Notes:
  • Filtering and sorting a dataset only affects the items displayed on your site, not the items in your collection.
  • Datasets with a "Write-only" mode cannot sort or filter, only "Read-only" or "Read-Write" modes can sort or filter. 
New datasets experience:
In Wix Studio, we've moved datasets to the Inspector panel on the right to make them easier for you to use. Learn more about the new datasets experience in Wix Studio

Filtering items on your site

Adding a filter to your dataset allows you to control what items will display. Use the following three values to define your filter:
  1. The field you want to filter by.
  2. The condition you want to use when checking whether items meet the filter criteria.
  3. The value you want the filter to match.
Note:
In the Dataset Settings panel, click + Add Filter to open the Add Filter panel.
Let's look at an example. Say you have a site that lists your favorite recipes, and you have categorized them by cuisine. Now you want to filter your dataset connector to only show your Tex Mex recipes. The field would be "Cuisine," the condition would be "Is," and the value would be "Tex Mex." The image below shows how this would look.

Field

Click the drop-down and select the field in your collection you want to filter. 

Condition

Click the drop-down and then select the filter condition for this field. The available filter conditions vary depending on the type of field you are filtering by. 
  • Text fields have conditions like "Is" or "Starts with." 
  • Number fields have conditions like "Greater than" or "Equals." 
  • Boolean fields can be either "True" or "'False."

You can only filter by a reference field if your page has a dataset that is connected to the referenced collection. Reference fields only have one condition, "Same as."

When filtering by the Owner field, you can choose between "Is" and "Is not" the currently logged-in user. 
Note:
You can also filter one dataset by a second dataset so you can display related information from more than one collection on the same page, even though the collections themselves are not connected with reference fields. See here for instructions.

Value

This is the value that you want to use for the filter condition you defined. 
  • In the case of reference fields, choose the referenced collection.
  • In the case of the "Owner" field, the "logged-in user" value is automatically filled in.

Changing or Removing a Filter

Once you have defined a filter, its description is listed in the Dataset Settings panel.
  • To change the filter, select it, click the ellipsis, and then click Edit.
  • To remove the filter, select it, click the ellipsis, and then click Delete.

Filtering by Multiple Fields

You can add more than one filter. For example, you might want to filter your recipes collection by the Tex Mex cuisine and also by whether they are gluten-free. 

When you define more than one filter, both filter conditions work together. This means that in order to be displayed, items must match both filter conditions. If no items in your collection meet both filter conditions, nothing will be displayed. 

Filtering Dynamic Pages

It is important to remember that dynamic pages are already filtered by their URL. This means that adding a filter condition to a dynamic page creates two filter conditions for that page.

In the case of a dynamic item page, the page will only be displayed if the item in question matches both the URL condition and the new filter condition. If someone tries to go to the page using its URL, they will get a 404 page. In the case of a dynamic list page, the page will only include items that meet both the URL condition and the new filter condition.

You can use this to your advantage to control which item pages can be displayed without needing to modify the URL. For example, you could add a field to your collection called "Active," and then add a filter condition based on that field so that only active items are displayed.

Sorting your content using a dataset

Sorting your dataset connector controls the order in which items are displayed in repeaters, tables, and galleries. If you have back and next buttons attached to your dataset, the sort controls the order in which the items appear when visitors use the buttons to navigate.

When you sort your dataset, you define two things:
  1. The field you want to sort by.
  2. The order in which you want the items to appear. 

The default sort order is the date the item was added, with newer items appearing first. This date appears in the "Date_Created" system field. When you add a new sort, the default sort disappears.

If we continue our example from above, we want the recipes to be listed alphabetically by recipe name. So our field would be "Recipe," and our order would be "A-Z."  The image below shows how this looks.
Note:
In the Dataset Settings panel, click + Add Sort to open the Add Sort panel.

Field

Click Choose to open the drop-down and select the field in your collection you want to use to sort your dataset. 

Order

Click the drop-down to select the sort order. The options vary depending on the type of field you selected. For example, number field can be sorted smallest to largest or largest to smallest. Boolean fields can be sorted as "True first" or "False first."

Changing or Removing a Sort

Once you have defined a sort, its description is listed in the Dataset Settings panel.

  • To change the sort, select it, click Show More, and then click Edit.
  • To remove the sort, select it, click Show More, and then click Delete.

Sorting by Multiple Fields

You can sort by more than one field, if you want. When you do, the items are sorted by the first sort condition and then by the second sort condition, and so on. 

This is relevant if you have more than one item that matches your first sort condition. For example, if you sort your recipes by cuisine, you might want to add a second sort by recipe name so that under each cuisine, the recipes appear in alphabetical order.

You might even want to consider adding a field to your collection specifically to use for sorting the items in your dataset connector. This could be a number field, for example, or some other field.

Did this help?

|