|
||
Each document in the Kentico CMS repository is of some type, such as news, product, article, etc. Each document type has its own fields. Our document type will describe a computer, so it will have a computer name, processor type, RAM size, disk size and a product image field.
Go to Site Manager -> Development -> Document types and click 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 the users in the administration interface)
•Document type code name: custom.computer (custom is your namespace to distinguish your 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.
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. Leave the default values:
Click Next.
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 () button to create the following fields. For each field, enter the values, click Save field 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 type: Input
•Form control: Text box
•Column name: ComputerProcessorType
•Attribute type: Text
•Attribute size: 200
•Field caption: Processor type
•Form control type: Input
•Form control: Drop-down list
•Editing control settings -> Data source: select Options and enter the following items into the text area, one per line:
Athlon;Athlon
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 type: Input
•Form control: Text box
•Column name: ComputerHddSize
•Attribute type: Integer number
•Field caption: HDD (GB)
•Form control type: Input
•Form control: Text box
•Column name: ComputerImage
•Attribute type: File
•Allow empty value: check the box
•Field caption: Image
•Form control type: Uploader
•Form control: Upload file
Click Next.
Now you need to choose the field that will be used as the document name. Choose the ComputerName field. It means that when you create a new computer document, its name will be automatically taken from the ComputerName value and this value will appear in site navigation and in the CMS Desk content tree.
Click Next.
In Step 5, you need to select the document types under which the computers can be added in the content tree. Click the Add document types button and add the Page (menu item) document type, which means the editors will be able to create computer documents only under pages, not under article or news documents in the content tree.
Click Next.
In step 6, you need to choose which websites will use this document type. Click the Add sites button and choose My website in the following dialog.
Click Next. In Step 7, you are asked to specify how documents of this type should be indexed for searching and displayed in search results. Select the following values in the drop-downs:
•Title field: ComputerName
•Content field: DocumentContent
•Image field: ComputerImage
•Date field: DocumentCreatedWhen
Leave the default values for the rest of the options and click Next.
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, DELETE operations and a default transformation.
You have learned how to define a new document type.
|
How the content is stored
As you already know, the new Computer document type has its own database table. Each document is stored in three tables: CMS_TREE (tree structure), CMS_Document (document properties and metadata) and the specific table of the given document type, in this case CUSTOM_Computer:
The system automatically ensures all operations on these tables. The advantage of this storage is that it's 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). |