Reference Fields within Global Fields

You can add a Reference field within a Global field while creating a Global field’s schema. You can then use this Global field in any content type.

Let’s look at an example to understand how developers can use Reference fields within the Global fields.

For instance, you need a website to frequently show author details along with each blog article on every blog post of a popular magazine. Furthermore, you need to make sure that the author information referenced for each blog post stays consistent across every blog written by a particular author.

To achieve this, you can create a child content type named “Author Details” that contains a “Single Line Textbox” field for the author’s name, a “Multi Line Textbox” field for the author’s address, and a “Rich Text Editor” field for the Author’s qualification details. Then create the parent content type, “Blogs" containing the header and footer content.

Now, create a Global field named “Blog Post”. Within this Global field, add the following fields:

  • Single Line Textbox field (for the Blog Title)
  • Rich Text Editor field (for the Blog Content)
  • Reference field (for the Author Details) that refers to the “Author Details” content type

To deploy referenced author details from the child entry consistently across the “Blog” parent content type, simply refer to the “Blog Post” Global field within the parent content type’s entries.

Let us understand how developers can work with Reference fields within Global fields.

Add the Reference Field to Global Fields

To add a Reference field to the Global field, login to your Contentstack account, go to your stack, and perform the following steps:

  1. Click the “Content Models” icon on the left panel and select Global Fields.
  2. Click on the + New Global Field button to create a new Global Field. Provide a suitable Name and Description for your Global field.
  3. Click on Proceed.
  4. Click on the “Insert a field” link and select the Reference field option from the Fields list that appears.
  5. Click on the “settings” gear icon and select Basic
  6. From the Referenced Content Type dropdown menu on the right-hand side, select the content type of which entries you need to refer to. Provide a suitable name to the referenced content type (e.g. Author Details).Reference_Fields_within_Global_Fields_1_no_highlight.png

    Additional Resource: Learn more about the difference between Single and Multiple Content Type Referencing.

  7. Once done with adding the Reference field within the Global field, click on either Save or Save and Close.

Note: You can add only those Reference fields that refer to multiple content types to your Global fields.

Was this article helpful?

Thanks for your feedbackSmile-icon

On This Page

^