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)
  • 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

Create content types via the Content types application.

  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 a 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 correspond 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.

Fields are created using 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.

  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, the following resrictions apply 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 Content items and fill in the required settings.
  4. In Form component, select the Content item selector.
  5. Add content types that are allowed to be linked via Allowed content type.
  6. Save the field.

Now, whenever you edit a content item based on the content type, you are able to link content items of the allowed content type, and then retrieve and use them 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. The parameters of the file upload (e.g., maximum file size) can be configured.

  1. In the Content types application, select a 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 you edit a content item asset based on the content type, you are able to upload binary files, and then retrieve and use them in your application’s code.

Content type representations in the API

The system provides extensive API for working with content types and content items in the code of your project. The API allows you to work with content type instances (content items) as:

  • Generated content type classes – classes generated by the system that allow you to work with content type fields using strongly-typed objects. Each field (database column) is represented by a property whose data type is based on the type selected for the given field. Xperience-specific fields (ID, GUID, etc.) are stored within the SystemFields property.