Content types
A content type is a template that defines the data structure, functionality, and behavior for all content items that are based on it. When creating content types, you determine their:
- Target usage (reusable content, pages, emails, headless items)
- Fields (define the content model and data structure)
- Editing form layout (the interface through which users create and modify the content items)
Create content types
To create a new content type:
- Open the Content types application.
- Select New content type.
- Fill in the following values:
- Content type name – the name that is displayed to users in the administration interface.
- Code name
Namespace – the namespace is a prefix that distinguishes between content types. For example, it can be used to separate content types created for different sites, identify content types imported as part of third-party modules, etc.
Name – a unique content type identifier, which is appended to the namespace.
Important
When creating content types, never use names beginning with an underscore (‘_’) character (e.g., ‘_article’) to avoid conflicts with system fields.
Always use a unique namespace. Never use the cms, om, content or ContentItemData prefixes. A recommended option is to use your company name or an abbreviation as the prefix. For example: ACME
- Icon – an icon identifying the content type when creating items (pages, emails, etc.).
- Use for – determines the target usage for the content type.
- Reusable content – intended for reuse across multiple channels and channel types.
- Pages – used for website channels.
- Emails – used for email content.
- Headless items – used for headless channels.
- Short code name – automatically generated based on the full Code name. Serves as a unique identifier of the content type in scenarios and environments where special characters (underscores and periods) are not supported, for example when generating type and field names in the GraphQL schema of headless channels. If you encounter a name conflict in these scenarios, you can edit the short code name value on the General tab of existing content types.
- Save the content type.
The system creates the content type and opens its configuration menu.
Configure created content types
When configuring content types, you determine their functionality and purpose.
You can:
- Add fields to a content type.
- Allow editors to link other content items.
- Allow editors to upload files to content items.
- Configure mass asset upload for a content type.
- Configure automatic image optimization for images uploaded to content items.
- Allow editor to tag content.
Add fields
Content type fields are used to store structured data. Each field corresponds to a database column and is of a certain data type. Developers access the content of fields from the code to format and display stored data.
You can create content type fields via the field editor on the Fields tab when editing a content type in the Content types application:
- Select New field.
- Define a custom field using the field editor.
- There are a couple of things to keep in mind when naming fields – see Field naming guidelines for more information.
- Save the field.
- Repeat the above steps to create all desired fields.
Content items based on this content type now allow editors to input data into the added fields.
Field naming guidelines
Since each field is represented as a database column and eventually a C# class, adhere to the following restrictions when naming fields:
- Don’t use the same name as another content type in the system.
- Don’t use C# keywords.
- Don’t use the name SystemFields.
Not following these recommendation can result in unexpected behavior, runtime errors, or uncompilable code.
Add the option to link content items
You can enable users to link content items from other reusable content items.
- In the Content types application, select the content type where you want to add the possibility to add linked content items.
- Create a New field.
- In Data type, select Pages and reusable content and fill in the required settings.
- In Form component, select the Combined content selector.
- In Display items based on, select whether you want to display items available in the selector based on Content types or a Reusable field schema.
- Add content types that are allowed to be linked via Allowed content types or select a Allowed reusable field schema.
- Save the field.
Now, whenever users edit a content item based on the content type, they can link content items of allowed content types. You can then retrieve and use the linked items in your application’s code.
Linked item limitations for emails
Linked content items may have their own fields that link to further content items.
When modeling the fields of content types for emails, the system has a limit of 5 nested content item levels. Further levels of linked items will not be loaded into the final email content.
Add option to upload files
You can enable users to upload binary files to content items of a certain content type to create content item assets. You can also configure the parameters of the file upload (e.g., maximum file size).
- In the Content types application, select the reusable content type where you want to add the possibility to upload files.
- Create a New field.
- In Data type, select Content item asset and fill in the required settings.
- In Form component, select the Asset uploader.
- Configure Allowed extensions.
- Save the field.
Now, whenever users edit a content item based on the content type, they can upload binary files to the item to create a content item asset. You can then retrieve and use the assets in your application’s code.
Mass asset upload configuration
You can allow users to upload multiple files in a single bulk into the Content hub and automatically convert them to content item assets of a specific content type. The system only supports converting all mass-uploaded files to a single content type.
- In the Content types application, open the Mass asset upload tab.
- Select the Content type for mass-uploaded items. You can select only a content type used for reusable content that has at least one content item asset field configured.
- Select the Content item asset field of the content type which will store the uploaded file.
- Save the settings.
Users can now mass upload assets into the Content hub.
Automatically optimize image assets
To ensure that your content editors work with images that are properly optimized for use across different channels, you can configure the system to automatically convert all newly created images to a single image format, and optimize their file size by adjusting image quality.
- In the Content types application, select the content type for which you want to enable automatic image optimization.
- In the Content item asset field, select Enable automatic image format conversion.
- Select Image extensions to convert. You can choose only optimizable image types that are allowed for the particular content type.
- Select a single Output image extension for the converted images. If you are not sure which image format to use for the content item asset, see the Image file type and format guide.
- Select the Quality level of the converted images.
- Quality selection is unavailable for image formats that use lossless image compression, like PNG.
- While higher quality retains more image details, lowering the quality reduces the output file size.
- Save the field.
Upon upload, images with the selected Image extensions to convert are automatically converted to images with the Output image extension in the specified Quality. Images with other extensions are uploaded without any optimization.
We recommend manually optimizing several sample images before enabling automatic optimization to fine-tune the optimization parameters for the best results.
If you notice undesired compression artifacts in the converted images, try increasing the quality until the artifacts are no longer visible.
Add option to tag content
You can enable content editors to add tags to pages and reusable content items.
- In the Content types application, select a content type for which you want to enable the option to tag content.
- Create a New field.
- In Data type, select Taxonomy and fill the required settings.
- In Form component, select Tag selector.
- In Taxonomy group, select from which taxonomy users can select tags in this field.
- Save the field.
Now, whenever you edit a content item based on the content type, you are able to add tags to the content.
Tip: You can add multiple taxonomy fields to a single content type, each with a different set of tags.
Work with content types in custom code
The system provides code generation support for objects that contain custom fields. The resulting generated classes are plain data transfer objects that work seamlessly with Xperience’s data retrieval API.
Whenever you modify a content type’s fields (add or remove fields, change the field’s data type), you need to regenerate the corresponding classes using the code generator. This keeps the models consistent with the content type’s database definition.