Schema definition will generate a content input form. Text schema can include other Text Schema or Binary Schema. In the <<Quick start>> document, we already talked about basic of Text Schema.
1. Column definition
Add path: Application --> SiteManager --> Schema --> Text, click "New" button to add a new text schema
Schema definition page looks like:
In the "Columns" tab, move your mouse to any of the columns such "name" or "label", a down arrow will appear. Click on the arrow will open below screen.
Name, Label, DataType and ControlType are the common settings of a field. Besides that, there are some more advanced settings.
ColumnId: System generated value
UUID: System generated value
OriginalUUID:System generated value
Name: How you name your field, also the key for accessing content from API.
Label: The text label that will appear on the content input form.
DataType: The datatype of this field, like string, date or number.
Length: The length of your data. This feature will be used in the next version.
ControlType: The type of control to use when generating the schema content input form. Advanced user can define their own ControlType using Javascript. Example ControlTypes are text, checkbox and htmleditor.
Selection Items: The items to be used for dropdown or checkbox value. Value format are: name1:::value1|name2:::value2
VisibleInList: If checked, this column will appear in the CMS content list page.
DefaultValue: Default value of this field.
Allownull: Allow null value.
CMS search: Whether this field will be included in the search field within this CMS backend or not.
Search Index: Include in the index file available for front end site search.
Modifiable: Can this column data editable in the editing form. When false, field can not be modified after creation.
SortOrder: DESC or ASC. By default content is sorted by the modify date
VType: Built-in basic validation group. Currently Kooboo has alpha, alphanum, email and url. It can be extended using JavaScript.
Validation Group: Self defined validation group.
2. Advanced setting
Click the "Advanced" tag, you will some advance settings.
User Key
If checked, content input form will contain a field called "User key". This key can be used for data query. It can be useful in scenarios like using a content type for some static pages,each with an own defined UserKey. A content template with a parameter of UserKey can be used to display those contents.
File included
When checked, the content input form will include a file upload box.You can upload unlimited number of files into this content item. The uploaded files will be accessible via our API. Please check our API document for accessing files uploaded.
File extension
Allowed file extension to be upload. For example: "jpg|gif".
Note: If you would like to include fixed amount of files in your Text Schema, you can use the ControlType: file.
Binary Schema
Reference to a Binary Schema. The content input form will include a dropdown list to view and select binary files based on the Schema defined. More detail in the Binary schema document.
Child Schema
Text content to be included within current content item. This is used for sub content of one content item. For example, one blog may have one or more comments. Comment is sub content of blog, one comment only belongs to one blog.
To use a Child schema, you have to add that child schema first. For example, for Schema blog to include comment, we first need to create a schema called "comment". After that we will be able to include "Comment" as a child schema for blog.
When a Child schema is defined, the content input form will include a sub form for child content. You can go to one content folder, and click one item:
You can get the below screen.
Sub content can be edited in CMS, some times may be added by user at front end site. For example, blog comment added at front end. Kooboo offer APIs for read & write sub contents. Below is an example method.
public IDictionaryAddSubContent(int parentId, string schemaName, string userName, NameValueCollection values, HttpFileCollectionBase files);
More information regarding the API can be found at Kooboo API reference chm file in the download section of Kooboo website.
Category
One content can refer to or belong to another content. This is similar as a foreign key in database table. It creates a "many to many" relation between
two content items. The most common situation are products belongs to a category and students belong to a class. "many to many" can be used for "1 to many" relation as well, there is no constraint rules implemented yet for the content relation.
Adding a category schema is similar as a child schema, you need to create both schemas first and then make the relation between them.
In the content input form, category schema will appear in a dropdown list to be selected from.
There is Data Rule to get Categories based on content or get contents based on Category. API access is also possible.
3. Validation rule and group
There are some built in Validation groups named Vtype. A validation Group contain one or more validation rules. Validation rule can be created using JavaScript. You can assign validation groups to a Schema field. When adding content, this field needs to pass validation check defined in the validation group.
Define Validation Rule
First you need to define validation rule using JavaScript. Below is an example of a validation rule.
function(value) {
if (value.length < 10)
return "the value must more than 10 letters";
return true;
}
When validation failed, it should return an error message. When success, return true.
Define Validation Group
You can define one or more validation rule into a Validation Group. In the schema definition page, check "Validation Group", and then on that field, select the group you just created.
After a Validation Group is assigned, the validation will be active during editing of that field.
4. Function
You can define your own function to be used on content list or detail page. On schema definition page, click "function" menu, then click "New" button to add a new user define function. There is only one Method defined in the interface, and a number of objects you can use to update "content".
Name: Can be anything.
Location: Tow options, List/Detail. List means appears in the content list page, Detail appears in the content detail page.
Script: Standard .NET script. There is some sample code to update content values when creating a function. You can modify to fit your needs.
After a function is created, you will be able to use your own function for content management.For example, go to the schema content list page, right click a item, you can see the function you just created.
