|
||
Each document in the Kentico CMS repository is of a certain type, such as news, product, article, etc. Every document type has its own data fields. Our document type describing computer products will have fields storing the computer name, processor type, RAM size, disk size and product image.
1. Go to Site Manager -> Development -> Document types and click New document type. This starts the New document type wizard.
2. Enter the following values in Step 1:
•Document type display name: Computer (the system displays this name to users in the administration interface)
•Document type code name: custom.computer (custom is a namespace to distinguish your document types from the default system types that use the cms namespace, computer is the identifier of the document type. You will use this value in the properties of controls later.)
Click Next.
3. In Step 2, you need to specify the name of the database table where the system will store the data of computer documents. You also need to enter the name of the table's primary key field. Leave the default values.
Click Next. The wizard creates a new database table for computer documents.
4. In Step 3, you need to define the fields of the document type (columns of the table). Click New attribute () to create the following fields. For each field, enter the values, click 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:
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: 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: yes (checked)
•Field caption: Image
•Form control: Upload file
Click Next.
5. In Step 4, choose the ComputerName field as the Document name source.
This means that when a user creates a new computer document, the system automatically fills in the document name based on the ComputerName value. The document name appears in site navigation and in the CMS Desk content tree.
Click Next.
6. In Step 5, select the document types that will be supported as parents for computer documents in the content tree. Click Add document types, select the Page (menu item) document type and click OK.
This means that users are only allowed to place computer documents under pages, not under articles, news items or other document types.
Click Next.
7. In Step 6, assign the document type to all websites where you wish to use it. Click Add sites, choose My website in the selection dialog and click OK.
Click Next.
8. Step 7 of the wizard allows you to specify how the Smart search module indexes documents of this type and displays them 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 configuration options and click Next.
9. Click Finish to complete the creation of the new document type.
The wizard automatically creates not only the database table, but also the SQL queries for SELECT, INSERT, UPDATE, DELETE operations and a several default transformation.
|
How does the system store document content?
The CMS stores document content and all related data in three database tables:
•CMS_TREE (content tree structure) •CMS_Document (general document properties, metadata and editable region content) •The dedicated document type table - in this case CUSTOM_Computer (stores the values of the document type's specific fields)
The system automatically ensures all operations related to these tables. You can easily write standard SQL SELECT queries to retrieve data from the repository (i.e. the Microsoft SQL Server database).
|
You have learned how to create new document types. Continue in the Transformations topic, which describes how to define the format used to display document data on the website.