Orchard CMS 1.4:向自定义 ContentPart 添加文本字段 [英] Orchard CMS 1.4: Adding a Text Field to Custom ContentPart
问题描述
在自定义 ContentPart 的模块中,如何将字段设置为文本字段?
In the module for a custom ContentPart, how do I set a field to be a Text field?
在我的 migrations.cs 类中,我为零件创建了表:
In my migrations.cs class, I have created the table for the part:
public int UpdateFrom1()
{
SchemaBuilder.CreateTable("RightContentPartRecord", table =>
table.ContentPartRecord()
.Column<string>("Html"));
return 2;
}
所以,我有一个名为 Html 的列.我想使用 WYSIWYG 编辑器,所以我被告知我需要一个文本字段来让它开箱即用"工作.
So, I have a column called Html. I want to use the WYSIWYG editor, so I am told I need a Text field to get this to work "out of the box".
但是,这不会发生在我身上,那么我需要做什么才能将名为 Html 的列转换为部件上的文本字段?
However, this isn't happening for me, so what do I need to do to turn my column called Html into a Text field on the part?
我该如何配置它以使用 WYSIWYG 编辑器?
And how do I configure it to use the WYSIWYG editor?
推荐答案
文本字段与部件属性不同.字段不存储为它们自己的数据库列.以下是如何向迁移中的部件添加字段的示例:
A text field is not the same thing as a part property. Fields are not stored as their own database column. Here is an example of how you add a field to a part from a migration:
ContentDefinitionManager.AlterPartDefinition("Product",
builder => builder.WithField("ProductImage", fieldBuilder => fieldBuilder.OfType("MediaPickerField").WithDisplayName("Product Image")));
对于文本字段,您还需要通过将 .WithSetting("Flavor", "html")
添加到字段构建器来设置风味设置.
For text field, you'd also need to set the flavor setting by adding .WithSetting("Flavor", "html")
to the field builder.
这篇关于Orchard CMS 1.4:向自定义 ContentPart 添加文本字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!