Content types
A content type is a template that defines the data structure, functionality, and behavior for all content items and pages that are based on it. The most important configuration options when creating content types are:
- Fields (define the content model and data structure)
- Editing form layout (the interface through which users create and modify the content items)
- Features (determine how content items behave, their URLs, etc.)
Content types and page types
Content types were previously known as page types. The rename was done as part of the introduction of the Content hub application and content items.
Create content types
You can create custom content types via the Content types application. A content type falls into one of the following categories:
- Standard content types – content types that hold structured data in customizable fields. Depending on the enabled features, the visual design of content items can be fully controlled by the site's developers or driven by the Page Builder for pages.
- Content types without fields – do not contain any custom fields and are created without a dedicated database table. Can be used for various purposes, such as:
- For pages that are purely driven by Page Builder.
- For pages used to categorize other pages in the website content tree.
To create a content type
- Open the Content types application.
- Select New content type.
- Fill in the following values:
- Content type display name – the name that is displayed to users in the administration interface.
- 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, or content prefixes. A recommended option is to use your company name or an abbreviation as the prefix. For example: ACME
- Decide if the content type requires custom fields.
- Save the new content type.
Using the provided information, the system creates a basic content type definition and opens the content type's configuration menu.
Configure created content types
Content type configuration is the next step after creating a content type. Your choices throughout this process determine the content type's functionality and purpose. The resulting content may represent actual pages available on the live site or serve as data containers used by other content.
Enable page features
Depending on their intended purpose in the system, content types can have multiple page features enabled. Features can be selected on the Features tab when editing a content type in the Content types application.
Note that some features may not be available for editing if content items of the particular content type were already created.
You can select from the following features for each content type:
- Page – specifies that the content item is a page. I.e., the content item has a representation in the page tree and further page features can be enabled.
- URL – pages of the type have their own URL that allows access on the live site. Editors can configure the URL in the Pages application. Selecting this feature also enables the Page feature – the content item must be in the content tree to enable content tree-based routing.
- Page Builder – allows editors to manage page content via Page Builder. This page feature is required to work with configurable widgets, and adjust the layout of pages by selecting page templates. The page builder feature must also be enabled in code. Selecting this feature also enables the URL feature – it's not possible to edit page builder pages without the page being accessible in some form.
Save your configuration. All content items based on this content type now have the selected features.
Add content type 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 contents of each field from the code of the .NET application 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:
- Select New field.
Define a custom field using the field editor.
Save the field.
- Repeat the above steps to create any number of fields.
Content items based on this content type now allow editors to input data into the added fields.
Add option to link content items
You can enable users to add linked content items when editing content items or pages of a certain content type. Linked content items are stored in the database and can be retrieved through the API.
- In the Content types application, select a content type where you want to add the possibility to add linked content items.
- Create a New field.
- In Data type, select Content items and fill in the required settings.
- In Form component, select the Content item selector.
- Due to certain limitations of the implementation, you need to Save the field before you are able to select the allowed content type.
- Edit the created field and select the Allowed content type.
- 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.
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.
- In the Content types application, select a 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.
- Due to certain limitations of the implementation, you need to Save the field before you are able to select the allowed extensions.
- Edit the created field and select the Allowed extensions.
- 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 the .NET application. The API allows you to work with content type instances (content items) as:
TreeNode
objects – a general class representing all types of content items in the system. Allows strongly-typed access to data shared by all content items (title, ID, GUID, creation date, publish date, etc.). Fields specific to content types can only be accessed using the GetValue method and specifying desired column names.- 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. The property's getter and setter contains logic that retrieves/stores the field data using appropriate API. These classes inherit from the
TreeNode
class and therefore allow access to all general content item data (title, ID, GUID, creation date, publish date, etc.) as well.