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:

  1. Open the Content types application.
  2. Select New content type.
  3. 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.
  4. 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.

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:

  1. Select New field.
  2. 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.
  3. Save the field.
  4. 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.

You can enable users to link content items from other reusable content items.

  1. In the Content types application, select the content type where you want to add the possibility to add linked content items.
  2. Create a New field.
  3. In Data type, select Pages and reusable content and fill in the required settings.
  4. In Form component, select the Combined content selector.
  5. 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.
  6. Add content types that are allowed to be linked via Allowed content types or select a Allowed reusable field schema.
  7. 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).

  1. In the Content types application, select the reusable content type where you want to add the possibility to upload files.
  2. Create a New field.
  3. In Data type, select Content item asset and fill in the required settings.
  4. In Form component, select the Asset uploader.
  5. Configure Allowed extensions.
  6. 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.

  1. In the Content types application, open the Mass asset upload tab.
  2. 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.
  3. Select the Content item asset field of the content type which will store the uploaded file.
  4. Save the settings.

Users can now mass upload assets into the Content hub.

Add option to tag content

You can enable content editors to add tags to pages and reusable content items.

  1. In the Content types application, select a content type for which you want to enable the option to tag content.
  2. Create a New field.
  3. In Data type, select Taxonomy and fill the required settings.
  4. In Form component, select Tag selector.
  5. In Taxonomy group, select from which taxonomy users can select tags in this field.
  6. 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.