Dynamic content types

Overview

Purpose of content types

Each module has one or more content types. When you use different content types, you can make each content type to have different fields – for example, within the same module, you can have one content type with fields Name and Description, and another content type with fields Name and Image.

Navigation

Each module appears under the Content tab, together with all of its first level content types – you can use it to create dynamic content items. When you open a module, the first level of the hierarchical content types appears.
For more information, see Dynamic content items » Navigate between the content types of a module

Sitefinity CMS also adds a new widget group for each module and adds one widget for each content type, for example – Countries. You use this widget to display the content items created with this module.
For more information, see Dynamic content widgets.

Hierarchy of content types

A module must have at least one content type. You create this type when you create the module. A module with one type can be, for example, an FAQ module, whose content type can be FAQs and FAQs can have two fields – Question and Answer. You can also have more than one content type in one module and you can have a hierarchy of the content types. For example, the built-in Forums module has Forums and Threads content types, and Thread is a child of a Forum.

EXAMPLE: You can also have multiple content types in one level of hierarchy – one content type can be a parent of more than one content type. You can build a module named Vacations. This module can have a content type Countries. Content type Countries can have children – Cities and Resorts. Cities can have children – Hotels, Restaurants, and Museums and Resorts can have children Bars and Beaches.

Create a dynamic content type

You create content types from the module’s detailed page.

  1. In Sitefinity CMS backend, navigate to Administration » Module builder.
  2. Click the module where you want to create a content type.
    The module’s detailed page appears.
  3. Click Add a content type button.
  4. In Content type (singular), enter the singular name of the content items that the module will store.
    For example, the singular name of the content type of the Events module is Event. For the FAQ module, you can enter, Question.
  5. You can change the automatically generated name that is used to refer to the content type in the code.
    To change it, in Developer name of this content type, enter the new name.
    You must use a valid .NET class name. For more information, see MSDN » C# coding conventions.
  6. To create hierarchical content types, in the Parent content type dropdown box, select the parent content type of the content type you are creating.

    For example, Blogs are parent content type of Blog posts.

    NOTE: Each content type can have multiple child content types.

  7. Add the fields of the content type by clicking Add a field…
    The system then takes you to create a custom field. for more information, see  Create custom fields.
    You must create at least one field that is of type short text and required.

    For example, in the FAQ module, the content items can have a short text field Question, a long text field Answer, and you can also classify the questions, using categories.

    NOTE: If you have chosen to add Choices field, such as radio buttons or multiple choice, you must enter a value for each choice you create. The value must be unique of each choice. It is not visible by users in the interface. Keep values as short as possible. You can enter, for example, 1, 2, and 3. These numbers are used by developers to refer the choice in the code.

    NOTE: If you are using multiple backend or frontend languages, you can automatically display the label in the respective language. This is valid for choice fields, such as radio buttons, dropdown boxes, and multiple choices. This way the choices of a radio button are displayed in the respective language automatically. To do this, create a new label using procedure Create labels. Copy the Key and the Type of the label. Then when you enter a choice, in the input field, enter the following: Resources:<Type of resource>, <Key of resource>.

  8. In Which field is the identifier of the content? dropdown box, select which field will be used to represent the content item and to generate its URL.
    You can select only a short text field that is marked as required.

    For example, if you have entered a frequently asked question How to install a module, then in the list of content items this question will be listed as How to install a module and its URL will be how-to-install-a-module.

  9. To be able to set individual permissions for each field of the content type, expand Advanced and select Allow permissions per field checkbox.
    For example, some users can change the answer to an FAQ; others can only view it, but can create questions.
  10. Click Finish.
  11. To create more content types, click Add a content type and perform this procedure again.

Edit dynamic content types and their hierarchy

Once you created a content type, you can edit its properties, fields, and the hierarchy between content types.

If your module has more than one content type, you can have either a flat structure – all content types are on one level, or you can have hierarchy, some content types are parents of other content types. You choose the parent of a content type when you create it, but you can change this parent when you edit the content type.

To edit a content type, create a new content, or change the hierarchy of your content types, perform the following:

  1. Click Administration » Module builder.
  2. Click the module whose content type you want to edit.
    The module’s detailed page appears.
  3. Under This module contains..., click the content type.

Edit the content type

To edit the content type, perform the following:

  1. Edit the properties and the fields of the content type.
    For more information, see Create a dynamic content type above.

    NOTE: If you want to change the identifier of the module, you must also update the grid, displaying the content items. For more information, see Change the identifier of a content type bellow.

  2. To change the hierarchy, you must select a new parent in the Parent content type dropdown box.
  3. Click Finish.

Delete the content type:

NOTE: You must have at least one content type. If you have only one content type, the Delete link is not available.

To delete the content type, perform the following:

  1. In the lower-right corner, click Delete.
  2. Confirm the deletion.
    The content type and all content items create with it are permanently deleted.

Hierarchical changes

If you have changed the parent type of a content type, the system cannot map all the items of this type with respective parent items of the new parent type. You make this mapping manually. For this purpose, the system automatically creates an item in the parent content type, named Moved items. This item, by default becomes a parent item of all items of the content type that you have moved. 

EXAMPLE: If you have two content types – Blogs and Blog posts, which are both at top level. You have created a couple of blogs and some blog posts. Later, you decide that you want to make Blog posts a child content type of Blogs, meaning each blog will have its own blog posts. You open Blog posts content type for editing and you select as parent Blogs. The system moves all created blog posts under the Blogs content type, but it does not know which blog post will belong to which blog. Therefore, the Moved items item is created and it becomes a parent of all blog posts. If you open the Moved items item, you can see all blog posts and you can edit each blog post and assign it to a particular blog, by changing its parent.

Change the identifier of a content type

Once you create a content type, you can edit, reorder it, or delete it.

If you want to change the identifier of a content type, you need to also edit the grid that displays the content type items. The identifier is used to list the content items in the grid. Under the identifier, you also have the link to create child content type items.

EXAMPLE: You have a content type, named Authors. The identifier of this content type would most conveniently be the author’s name. Thus, in the Authors’ grid, Sitefinity CMS lists all created authors by their name. If Authors has a child content type – Books, then below the name of each author in the grid, Sitefinity CMS displays a link to create books from this author. If you decide to change the Authors’ identifier, for example, to be an ID number, then you must also add the ID column to the grid. Otherwise, you will not see the new identifier in the grid and you will not be displayed the link to create books.

When you change the identifier of a content type, perform the following:

  1. Navigate to Administration » Module builder.
  2. Click the module, which the content type belongs to.
  3. Click Backend screen tweaks.
  4. Under Listing <your module name>, click Add/Remove columns in the table (grid).
  5. From the right pane, drag the new identifier and drop it in the desired place under Existing columns.
  6. Save your changes.

RECOMMENDATION: If you plan to change the identifier of a content type, make sure all content items have value for the new identifier. The identifier must be a required field, but, if you want to use a new field for identifier, we recommend to first add the new field to the content type, then fill out the field for each content item, and, finally, make the new field the content type identifier.

Want to learn more?

Sign up for our free beginner training. Boost your credentials through advanced courses and certification.
Register for Sitefinity training and certification.

Was this article helpful?

Next article

Dynamic content items