0

我是 N2 CMS 的新手,我被困在动态内容中,比如添加 n 个时间项。这是一个示例 该对象包括:

        WYSIWYG / Richtext Editor (This will be [EditableFreeTextAreaAttribute])
        **n-times item**
           caption  [EditableText]
           image  [FileAttachment]

我的问题是,我怎样才能在我有 1 个 RTE 和 n 次标题和图像的情况下使它成为 N 次。目前我坚持下去。请建议我如何想出这个。

谢谢。

4

1 回答 1

1

看看 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

于 2015-08-26T19:52:29.673 回答