Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
I also noted that if you set TargetType to the block, it only triggers for local blocks. I ended up switching up to using TargetType = typeof(ContentData) and then check in editor descriptor what type of content is being created. That works for shared blocks. Example to hide LinkUrl property on contact block for alloy site:
[EditorDescriptorRegistration(TargetType = typeof(ContentData))]
public class MoveFormsPropertyEditorDescriptor : EditorDescriptor
{
public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
{
var contentDataMetadata = (ContentDataMetadata)metadata;
if ((contentDataMetadata.Model as ContactBlock != null))
{
foreach (var metadataProperty in metadata.Properties)
{
var mp = metadataProperty;
if (mp.PropertyName == nameof(ContactBlock.LinkUrl))
{
mp.ShowForEdit = false;
}
}
}
}
}
I want to extend the group container for my block but when adding a EditorDescriptor it's executed when I use it as a local block but not as a shared block. What's the difference and how can I accomplish this with a shared block?
[EditorDescriptorRegistration(TargetType = typeof(MyBlock))] public class MyBlockEditorDescriptor : EditorDescriptor { public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable attributes)
{
base.ModifyMetadata(metadata, attributes);
metadata.Properties.Cast().First().GroupSettings.ClientLayoutClass = "MyBlockContainer";
}
}