You can add Group fields within a Global field while creating a Global field’s schema. This allows you to reuse repetitive Group field structure across several content types instead of creating them every time.
Let’s consider an example to understand how we can place Group fields within Global fields.
Consider a scenario where a specific banner or advertisement needs to appear on every webpage of your healthcare website. Along with the banner, you also need to display helpful links related to the current webpage.
To achieve this, you need to create a Global field named “Advertisements and More”. Within this Global field, add a Group field named “Banner”. Then, within the Group field, add a Single Line Textbox field (for the Banner Title), a Rich Text Editor field (for the Description), and a File field (for the Banner Image), and Link field (for helpful links to related content).
Once done with creation of the Global field, you can create content types for each health related article on your healthcare site. Now, you can refer to the “Advertisements and More” Global field within any content type to consistently display the banner details and helpful links across every webpage of your site.
Let us look at how developers can work with Group fields and Global fields.
Add the Group Field to Global Fields
To add a Group field to the Global field, a developer can perform the following steps:
- After opening your stack, go to Content > Global Fields.
- Click on the + New Global Field button to create a new Global field. Provide a suitable Name and Description to your Global field.
- Click on Create and Add fields.
- Click on the Group field option and drag and drop the field from the Fields list displayed at the left-hand side. Provide a suitable name for your Group field (for e.g. Banner).
- Now, from the left panel, add fields of your choice into this Group field (for e.g. a Single Line Textbox field for the banner title or a Rich Text Editor field for the banner description).
- Once done with adding fields within the Global field, click on either Save or Save and Close.
- Now, go to the Content Type Builder page of any content type, drag and drop the Global field from the left-hand side pane, and select the Global field you just created (for e.g. Advertisements and More) from the Select Global Field dropdown menu.
Note: When you add a Group field to your Global field, each Group field counts as a single level of nesting.
You will notice that the entire set of subfields within the Global field automatically load onto the Content Type Builder page.