Kentico CMS 7.0 Developer's Guide

Defining a new document type

Defining a new document type

Previous topic Next topic Mail us feedback on this topic!  

Defining a new document type

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

In this example, you will learn how to define a new custom document type.


1. Go to Site Manager -> Development -> Document types and click AddNewDocumentType New document type. You will be redirected to the New document type wizard. In the first step, enter the following values:


Document type display name: Computer (this name will be displayed to users in the administration interface)

Document type code name: (custom is your namespace to distinguish your own document types from system types that use the cms namespace, computer is the document type). You will use this value in web part properties later.


Click Next.




2. In Step 2, you need to choose the name of the database table that will be used for storing computer details. You also need to enter the name of the primary key in this table. Enter the following values:


Table name: CUSTOM_Computer

Primary key name: ComputerID

Inherits fields from document type: (none)


Click Next.




3. The wizard has created a new database table for computers. Now you need to define the fields of the document type (columns of the table). Use the New attribute (AddWebPart) button to create the following fields. For each field, enter the values, click Save Save and repeat the procedure until you have all the listed fields defined.


Column name: ComputerName

Attribute type: Text

Attribute size: 200

Field caption: Computer name

Form control: Text box


Column name: ComputerProcessorType

Attribute type: Text

Attribute size: 200

Field caption: Processor type

Form control: Drop-down list

Editing control settings -> Data source: select Options and enter the following items into the text area, one per line:


Pentium XEON;Pentium XEON

Pentium Core 2 Duo;Pentium Core 2 Duo


Column name: ComputerRamSize

Attribute type: Integer number

Field caption: RAM (MB)

Form control: Text box


Column name: ComputerHddSize

Attribute type: Integer number

Field caption: HDD (GB)

Form control: Text box


Column name: ComputerImage

Attribute type: File

Allow empty value: Enabled (check the box)

Field caption: Image

Form control: Upload file




Please note that you can also define system fields that will be displayed when editing documents of this type on the Form tab. This can be done by clicking the New system attribute (AddNewSystemAttribute) button. Using the Group drop-down list, you can then choose from the following two groups of system fields:


Document attributes - offers the system fields of documents.

Node attributes - offers the system fields of content tree nodes.


Document or node system fields will then be offered in the Attribute name drop-down list. If you leave the Display attribute in the editing form check-box checked, the field will be visible on the document Form tab.


Click Next.




4. Now you need to choose the field that will be used as the name for document's of this type. Choose the ComputerName option from the drop-down list. This ensures that computer documents will use the value of the ComputerName field as the name displayed in site navigation and in the CMS Desk content tree.


Click Next.




5. In Step 5, you need to select the document types under which computer documents will be displayed. Check only the Page (menu item) value, which means that editors will be able to create computer documents only under some page, not under an article or news document in the content tree.


Click Next.




6. In Step 6, you need to choose which websites will use this document type. Check the appropriate website and click Next.




7. In Step 7, you are asked to specify how documents of this type will be indexed and displayed in the search results. For more information on these settings, please refer to this topic. Make your choice and click Next.




8. The wizard has finished the configuration of the new document type. It has automatically created not only the database table, but also the SQL queries for SELECT, INSERT, UPDATE and DELETE operations and default transformations.


Click Finish. Congratulations, you have learned how to define a new document type.






How the content is stored


As you already know, the new document type Computer has its own database table for its specific fields. Each document is stored in three tables: CMS_TREE (tree structure), CMS_Document (document properties, metadata and content defined on the Page tab) and the custom table - in this case CUSTOM_Computer:




The system automatically ensures all operations are performed correctly on these tables. The advantage of this storage is that it is very fast and you can easily write standard SQL SELECT queries to retrieve data from the repository (i.e. from the Microsoft SQL Server database).