Cardboard CMS now supports custom extension field

Cardboard CMS now supports custom fields without modifying the code, and can be extended fields, such as pages, articles and products of some of the modules in the system.

Custom Fields functionality in System -> Under the Custom Fields menu, click on the module you want to modify, you can be on the field, the meaning of words:

Here you can adjust the order of the fields, add or delete fields:

 

Operation field, you can refer to this article: http://www.zkea.net/codesnippet/detail/zkeacms-formgenerator.html

Using Extended Field

Extended fields and fields in the system meaning the use or different. The information is stored in the extended field Model.Propertiesattributes below, when used in the template, we try to make them and the general fields with no difference between them. For example, adding an extension field: CustomProperty, its use will be described below.

Razor

In Razor In use, if it is specified in the Model, by will have Getdirect access to the acquisition method, or converted into a dynamic type of the type

@model ArticleEntity
<h1>
    @Model.Get("CustomProperty")
</h1>
<h1>
    @(((dynamic)Model).CustomProperty)
</h1>

If no type Model, Model type is dynamic, and can be used as the normal field use custom fields 

<h1>
    @Model.CustomProperty
</h1>

Fluid

在fluid模板中使用和普通字段一样:

<h1>{{this.Model.CustomProperty}}</h1>

Json序列化

在服务端将对象用json方式序列化返回客户端时,中序列化的结果中,自定义字段和普通字段一样,结果如下:

{
    title:"Test",
    customProperty:"PropertyValue"
}

在客户端提交数据时,当作正常字段提交处理即可: 

$.ajax({
    type: "POST",
    url: "/webservices/CreateMarkers",
    data: JSON.stringify({ title: 'Name',customProperty:'PropertyValue'}),
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(data){alert(data);},
    failure: function(errMsg) {
        alert(errMsg);
    }
});

原文地址:https://www.zkea.net/zkeacms/document/extend-property

Guess you like

Origin www.cnblogs.com/seriawei/p/zkeacms-custom-property.html