Posted on 07/12/2020 14:50:25
Was hoping for a working example, but we can try and do it like that aswell ofc.
Here you go:
[Item("My Example Item")]
[AreaRule,
ModuleAttachmentRule(false),
StructureRule(StructureContextType.Paragraphs),
ParentRule(ParentRestrictionRule.ParentType.ItemType),
]
[Category("Paragraphs")]
[Icon(KnownIcon.CropLandscape)]
public class MyExampleItem : ItemEntry {
[Group("General")]
[Name("Content")]
[ItemTabEditor("Content", "MyContentExampleItem")]
public ItemTabEditorAttribute Content { get; set; }
public override void Delete(ItemContext context) {
base.Delete(context);
}
public override void Save(ItemContext context) {
base.Save(context);
}
}
[
Item("Content"),
AreaRule,
ModuleAttachmentRule(false),
StructureRule(StructureContextType.ItemList),
Category("Partials"),
Icon(KnownIcon.FileTextO)
]
public class MyContentExampleItem: ItemEntry {
[Group("General")]
[Name("Heading")]
public string Heading { get; set; }
[Group("General")]
[Name("Text")]
[RichText]
public string Text { get; set; }
public override void Delete(ItemContext context) {
base.Delete(context);
}
public override void Save(ItemContext context) {
base.Save(context);
}
}
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
public class ItemTabEditorAttribute : ItemTypeEditorAttribute {
public ItemTabEditorAttribute(string name, string itemType) : base(name, itemType) {
EditorType = typeof(ItemTypeTabEditor);
}
protected override void InitializeEditorConfiguration(ItemField itemField) {
ItemTypeTabEditor itemListEditor = new ItemTypeTabEditor() { ItemType = ItemType };
itemField.EditorConfiguration = itemListEditor.GetParametersToXml(false);
}
}