CMS: About Displaying Content from Multiple Collections Using Datasets

3 min read
You can see a How To article for this topic here.
Filtering by dataset lets you display related information from more than one collection on the same page, even though the collections themselves are not connected. 

For example, this could be helpful if you want to display a page with
  • All the songs associated with the same album or artist.
  • All the recipes in your collection associated with a specific cuisine and a description of that cuisine.

Additionally, filtering by dataset is convenient when you have information that relates to multiple items in a collection so that you can avoid duplicating data unnecessarily. 


For example, say you have a page that lets your users pick a cuisine from a list and then displays the description of that cuisine and all the relevant recipes from your collection. 
To avoid unnecessary duplication, you stored the cuisine descriptions in a separate collection from your recipes. Your Recipes collection includes a field called "Cuisine" that lists the cuisine for each of the recipes, but no description. Your Cuisines collection has an item for each cuisine along with a description.
Make sure the values in both collections are identical. Otherwise the filter will not find the right items.

Setting Up Your Page

On your page, add the screen elements that display the information about your recipes. In our example, we have a table to display the list of cuisines, a text element to display the cuisine description, and a gallery to display the recipes from the selected cuisine.
If you are filtering by dataset, a field in the secondary dataset will be linked to the current item value of the main dataset. You'll need to add a page element that allows you to switch between items in the main dataset. We used a table, but you can also use for example Previous and Next buttons. 

Adding the Dataset

Now you add your datasets. First add the main dataset, which in our case is the "Cuisines dataset." Next add the secondary dataset ("Recipes dataset" in this case) and filter it by the Cuisines dataset, so that the value in the "Cuisine" field in the Recipes dataset matches the value in the "Cuisine Name" field in the Cuisines dataset.

Connecting the Elements

Finally, you connect the screen elements to the datasets, just like you always do when displaying information from your collections. 
  • The table and text elements connect to the Cuisines dataset. They display the list of cuisines and the description of the selected cuisine. 
  • The gallery element connects to the filtered Recipes dataset, so that it can display the correct images based on the selected cuisine. 

Did this help?