CMS backend does almost all of the content editing tasks. Most of the data access task on front end site is data query. Data Rule is designed to make data query simple and effective. Data Rule visualize all data query operations. Users can define Rules on the page or template level. Data Rule will query data base on rules defined and make them available for template coding.
Data Rule configuration
DataName: Returned object name of this data rule. In above screen, we defined the name as "News", so we need to use this.GetContent("News")["FieldName"] to access the database on content template..
ValueType: The type of object to be returned. For example, List means a collection of objects, object means one object. Currently there are 8 ValueType can be returned.
Const: Const value, can be accessed directly from template.
Object: One content data, Kooboo will determine whether it is text or binary and return right objects.
List: A collection of content
Count: Total count of content match
GetContentsByCategory: get list of content based on category Schema Id and Folder.
GetContentCountByCategory: Get the total count value from Data Rule query.
GetCategoriesByContent: get list of category content based on content id and folder.
GetCategoryCountByContent: get the total count value from Data Rule query.
Folder: The folder which contains the content to be retrieved. All content in Kooboo must be stored on one folder.
Value Condition: The WHERE condition in standard SQL statement. You can use the value from query string as well. In the "Advanced" option of a page, there is a possibility to customize your URL. To use the value from query string, you can use {query string key} in page data rule value condition. For Data Rule defined for content template, you can also use [propertyname] in your value condition. [propertyname] will get the value from property defined in content template.
Reference Content ID: ContentId or Category ContentId depends or query type. Only used when query category based on content or content based on category.
OrderBy: Standard SQL order by syntax. For example ContentId DESC.
TOP: SQL SELECT TOP syntax, the TOP # of records to be returned.
Include Children: Include sub content.
Dynamic linking order: used for dynamic linking function.
Data rule execution
Data Rule can be defined on the Page or Content template. When there is a conflict of DataName, the later queried object will overwrite earlier object. When a Data rule is defined on a page, the rule will be executed by controller and placed in ViewData. When a data rule is defined on Content template, it will be executed on "OnPreRender" event of Content template.
