CMS: Using Reference Fields to Display Content from Multiple Collections

6 min read
Link one collection to other collections by using reference fields. Reference fields allow you to access all the fields and content stored in another collection. This allows page elements to display content from multiple collections. 
Definitions:
  • Main collection: a Content Collection connecting to another collection by using a reference field.
  • Referenced collection: the collection being connected to. 
  • Primary field: the field in the referenced collection, that connects to the main collection. 
  • Referenced field: the field in the main collection, that connects to the referenced collection. 

Step 1 | Define the primary field in the referenced collection

  1. Go to CMS in your site's dashboard.
  2. Select the referenced collection you want to connect to.
  3. Click the Title Field at the top of the column.
  4. Click the Make Primary of the field you want to set as primary.
In the example below, our Referenced Collection is titled "Menu".

Step 2 | Create a reference field in the main collection

  1. Go to CMS in your site's dashboard.
  2. Select the main collection from which you want to connect. 
  3. Click Manage Fields.
  4. Click + New Field to create a new field.
  5. Enter a Field Name.
  6. Select Reference as the Field Type.
  7. Select which collection you want to reference to under Referenced Collection.
  8. Click Save.
In the example below, our Main collection is titled "Recipes".

Step 3 | Fill in the reference field content in the main collection

  1. Click a cell in the Reference field column in the main collection.
  2. Select the value you want from the drop-down list. (The drop-down displays the content from the primary field of the referenced collection.)
Notes:
  • You can filter the list by typing letters that appear in the value you want to fill in.
  • If you change the main field in the referenced collection, the values in the reference field change to match the new main field.

Step 4 | Set up your element to display the referenced content on your page

Reference fields let you display content from different collections in the same element. You can display content from different collections using reference fields in:
  • tables (not yet available in Editor X)
  • galleries
  • repeaters
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

To set up an element on the page:

  1. Add a table, gallery or repeater to your page.
2.  Add a dataset to your page and connect it to your main collection:
3. Add a second dataset and connect it to the referenced collection. 
4. Add a filter to the second dataset so it only shows items from the main dataset. 
5.  Click an element in your table, gallery or repeater and click the Connect to Data icon
6.  Select the field in the referenced collection that you want to display.
Note:
In the drop-down, the reference field itself is grayed-out and displays the name of the collection it references. The fields in the referenced collection are indented beneath the reference field.
Editor X users:
The screenshot above is taken from the Wix Editor. The design might differ slightly in Editor X.

Looking for advanced information?

Did this help?

|