Reusable field schemas
When modeling site content, you may encounter situations where specific groups of fields keep repeating across content types. For example, each web page content type might need a basic set of fields such as title, date, and excerpt text. Or a set of fields dedicated to search engine optimization and social media promotion, such as for the Open Graph protocol or a specific platform (Twitter, etc.).
Reusable field schemas save you from having to repeatedly define similar fields across multiple content types. Instead, each schema can define a set of fields, often dedicated to a specific use case or scenario, that you then link to content types as required. All changes you make to a schema – adding, removing, or renaming a field, for example – get immediately reflected in all linked content types.
Create and assign reusable field schemas
- Open the Content types application and switch to the List of reusable field schemas tab.
- Select New reusable field schema.
- Enter the schema display name, code name, and description
- Save the schema.
- On the Fields tab, define schema fields using the field editor.
- There are a couple of things to keep in mind when naming fields – see Field naming guidelines
- Note: We strongly recommend prefixing all field names with the name of the reusable schema. For example, for a schema SEOFields, use SEOFieldsTitle, SEOFieldsDescription, SEOFieldsTags, and so on. This is to prevent column name conflicts between different schemas. See Remarks for details.
To assign created schemas to a content type:
- Edit a content type in the Content types application.
- On the Fields tab, select Add reusable schema.
- Select the schemas you want to assign and Confirm.
- Regenerate code files for the modified content type to access the added schema fields in your model classes.
This adds new bar items with the Reusable field schema label to the content type field listing. Each item represents a single schema and lists all fields that it contains.
The system treats fields assigned via reusable schemas as regular content type fields. You can retrieve and filter them via Content Item and GraphQL queries or access them using macros in email templates.
Unassign reusable field schemas
To unassign a reusable field schema, remove it via the content type Fields tab when editing content types in the Content types application.
- Open the Content types application and edit a content type.
- Switch to the fields tab.
- Find schema fields by the Reusable field schema label and remove them using the recycle bin () icon.
- Unassigning a schema also deletes all data stored by the removed schema fields for the corresponding content type.
Delete reusable field schemas
- Open the Content types application and switch to the List of reusable field schemas tab.
- Delete the schema using the recycle bin () icon.
- Note that you cannot delete a schema that is currently assigned to at least one content type. Unassign the schema from all content types first.
This removes the schema from the system.
Remarks
Field count limitations
All schema fields are stored in the CMS_ContentItemCommonData table. SQL tables have a maximum limit of 1024 columns per table. Therefore, a hard limit exists on the number of columns that can be defined for reusable schemas in a single instance.
Field name collisions
All schema fields are stored in the CMS_ContentItemCommonData table. When defining schema fields, prefix each field with the name of the corresponding schema to prevent column name collisions on the SQL level.