Docs / Tutorials / How to create a Content Type

How to create a Content Type

Content types define the structure of content:

A Content Type Definition is an XML-format configuration file for types. After creating a new Content Type Definition new content of the created type are immediately available in the system and can be created and used. The XML configuration (CTD) holds information about

In case default logic is not adequate and defining custom programmed logic is necessary a Content Handler for the type can be implemented in C# and the compiled library placed in the web folder’s bin directory. Attached business logic can also be added by implementing custom Fields and custom Field Controls.


In this section I will show you how to create a new Content Type step-by-step. To demonstrate the type definition capabilities of Sense/Net I will create a new Movie type that can be used to build movie data bases.

1.Login and go to Explore

The user must have administrator privileges - you may use the admin user with the default install. Explore is a management surface of the portal where you can navigate through the Content Repository and manage content. Start Explore by clicking on the Explore link in the Portal Remote Control, the floating black panel on the main page visible to administrators!

2.Navigate to ContentTypes folder and click New

This is where we will type in the Content Type Definition XML of our new type.

3. Insert Content Type Definition XML and click Install

Our new Movie type will have the following features:

The Content Type Definition for the Movie type will look something like this:

<ContentType name="Movie" parentType="GenericContent" handler="SenseNet.ContentRepository.GenericContent" 
  <Description>A simple movie type to build movie databases</Description>
    <Field name="Title" type="ShortText">
      <Description>Title of the movie</Description>
    <Field name="Year" type="Integer">
      <Description>Year of release date</Description>
    <Field name="Director" type="ShortText">
      <Description>Name of director</Description>
    <Field name="Plot" type="LongText">
      <Description>Plot outline</Description>
    <Field name="ImageRef" type="Reference">
      <DisplayName>Poster image (reference)</DisplayName>
    <Field name="ImageData" type="Binary">
      <DisplayName>Poster image (binarydata)</DisplayName>
    <Field name="Image" type="Image">
      <DisplayName>Poster image</DisplayName>
      <Bind property='ImageRef' />
      <Bind property='ImageData' />

Let’s go through the xml very quickly. There are some basic properties defined on the root element:

The main structure of the xml contains the following elements:

The following fields are defined in the Fields section:

You can go ahead - paste the xml into the content type editor box and click Install.

4.Use the created type

After installing the new Content Type Definition and refreshing the ContentTypes folder you should see the Movie type appeared under the Content type:

Now you can create new Movie content and manage them just like any other content. Stay in Explore mode, go to Default Site and click on New in the grid. In the appearing screen select Movie from the dropdown:

The edit ContentView of the type with the defined fields appears:

5.Modifying a Content Type Definition

You can view and edit the Content Type Definition of your type simply by navigating to the Content Type in Explore. A surface is provided with child Content Types, field information and available actions:

To edit the CTD click on the Edit link and the Content Type editor will appear. Click Install to save changes to the CTD.

Is something missing? See something that needs fixing? Propose a change here.