Content Template

Content template is used to display one or more content items. It has similiar concept as the user control in ASP.NET. It uses the syntax from ASP MVC to design the template. In the Kooboo Quick Start document, we have introduced Content Template.

Add path: Application --> Design --> Content template, click "New" button to create a new content template

The default template editor supports syntax highlight and intellisense. If that is not enough, you can also develop in Visual Studio.NET 2008. Visual Studio.NET has the benefits of intellisense and debug. After download Kooboo, you will find the a Visual Studio solution included in the ZIP. When you create a Content template or Layout template in the CMS backend, you will find a file created under the solution "template" folder. You can edit the template files and debug it.

When you are creating a new Content template using CMS, there are some sample code generated automatically. You can modify them for your needs.

Below are two common Content templates, news index page and news detail page.

News Index Content Template:



News Detail Content template


There are a few important API methods here. this.GetResource: Get resource value from "Text Resource". Resource often used for storing multilingual content. First parameter "NewsList" is a key name which is being used to look up Key/Value attribute in Text resource and the second parameter "New" is the default value in case Key/Value is not found.
this.GetContents: Get the list of content from "Data Rule". First parameter "News" is "Data Rule"->"DataItem" value. Using this.GetContents("News") returns an IEnumerable<IDictionary> object. More inforamtion about Data rule is explained the Data Rule document.
this.GetContent: Get one content object from "Data Rule". Because each content object is an IDictionary value, so item["Title"] will return "News" object "Title" value.
Html.PageLink: Kooboo's way of Linking. Kooboo will determine the correct URL to link to and verify existance of that URL. First parameter item["Title"].ToString() is the link text and second parameter "detail" is the page name and the third parameter "new {NewsId= item["ContentId"]}" is query string parameters for the destination page.
Data Rule: A visual tool Kooboo used to retrieve data.

There are another 3 important concepts of Content template: Property, Data Rule and Plugin.

Property
You can define a property in Content template to accept values pass from outside. You can use standard C# language to define a property.
For example:


On “Page” setting page, you will be able to see this defined property and assign a value to it or set the value to get from URL query string.


Data Rule

Content template can define its own Data rule. Data rule is Kooboo way of data access. Data rule will be executed on template OnPreRender event. We will describe more about this in the Data Rule document.

PagePlugin Extension. PagePlugin can be inserted into a Content template. PagePlugin handle the pre or after get/post execution of a page. For more information, refere to the page plugin document.