看看 EditableChildren 属性。基本上,您为子项定义一个内容项 - 例如。图片和标题。
然后你的主 ContentItem 有一个富文本编辑器和一个子内容项的集合。
例子:
namespace N2.Templates.Items
{
[PageDefinition("FAQ",
Description = "A list of frequently asked questions with answers.",
SortOrder = 200,
IconUrl = "~/Templates/UI/Img/help.png")]
[AvailableZone("Questions", "Questions")]
[RestrictParents(typeof(IStructuralPage))]
[ConventionTemplate]
public class FaqList : AbstractContentPage, IStructuralPage
{
[N2.Details.EditableChildren("Questions", "Questions", 110, ContainerName=Tabs.Content)]
public virtual IList<Faq> Questions
{
get { return GetChildren<Faq>("Questions"); }
}
}
}
https://github.com/n2cms/n2cms/blob/6b8698468b61cff0ee1825644b05b63d011bf7e8/src/WebForms/WebFormsTemplates/Templates/Items/FaqList.cs