0

I am new in N2 CMS and i am stuck in dynamic content like add n time item. This is an example This object consists of:

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

My question is, How I can make it N times where i have 1 RTE and n time Caption and image. Currently i am stuck on it. Please suggest me how I can comeup with this.

Thanks.

Riyadh Ul Islam
  • 172
  • 1
  • 7

1 Answers1

1

Take a look at the EditableChildren attribute. Basically you define a content item for the child item - eg. image and caption.

Then your main ContentItem has a rich text editor and a collection of the child content item.

Example:

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

BigJump
  • 15,561
  • 3
  • 31
  • 29