Ras*_*oov 3 episerver episerver-7
我有一个问题限制在ContentArea中插入什么类型的块.我想要的是SliderBlock的ContentArea属性只能插入一个SlideItemBlock.
[ContentType(...)]
public class SlideItemBlock : BlockData
{
[Required]
Display(Name = "Image")]
public virtual string Image { get; set;}
}
[ContentType(...)]
public class SliderBlock : BlockData
{
[Required]
[Display(Name = "Slides")]
public virtual ContentArea Slides { get; set; }
//Should only accept insertion of SlideItemBlock
}
Run Code Online (Sandbox Code Playgroud)
或者这是否是错误的方法来实现我试图限制编辑器不拖放错误的块类型?
截至目前,我可以创建一个SliderBlock并在其中插入一个SlideItemBlocks.如果我然后在新的SliderBlock中插入创建的SliderBlock,我会得到一个永远的循环,它会打破网站.这就是我想要控制的.
小智 5
如果您使用的是EPiServer 7.5,则可以限制内容区域中可以使用的块.有关详细信息,请参阅此博客文章:限制内容区域中允许的类型.
博客文章中的代码示例:
[EditorDescriptorRegistration(TargetType = typeof(ContentArea), UIHint = "Gallery")]
public class ImageGalleryEditorDescriptor : EditorDescriptor
{
public ImageGalleryEditorDescriptor()
{
// Setup the types that are allowed to be dragged and dropped into the content
// area; in this case only images are allowed to be added.
AllowedTypes = new Type[] { typeof(IContentImage) };
// Unfortunetly the ContentAreaEditorDescriptor is located in the CMS module
// and thus can not be inherited from; these settings are copied from that
// descriptor. These settings determine which editor and overlay should be
// used by this property in edit mode.
ClientEditingClass = "epi-cms.contentediting.editors.ContentAreaEditor";
OverlayConfiguration.Add("customType", "epi-cms.widget.overlay.ContentArea");
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3966 次 |
| 最近记录: |