HomeGuidesAPI Reference
Submit Documentation FeedbackJoin Developer CommunityOptimizely GitHubOptimizely NuGetLog In

Inline edit blocks

This topic describes inline edit blocks that simplify editing for common properties.

The inline edit dialog box is designed to be simple while still letting editors edit the most common properties of a block.

11071107

This is the reason why Optimizely introduced the InlineBlockEditSettings configuration attribute. You can apply it to your block content type and hide/show the Name and Categories properties. Additionally, you can also use this attribute to hide specific groups to make the editing form cleaner.

The attribute contains three properties:

PropertyDefault valueDescription
ShowNamePropertyfalseWhen true, then Name property is displayed.
ShowCategoryPropertyfalseWhen true, then Categories property is displayed.
HiddenGroupsAdvancedComma-separated list of tabs that should be hidden.

📘

Note

Advanced group is the Settings tab in the user interface, which is hidden by default in the inline edit dialog box.

Change settings for a specific block content type

To turn on the Name property for a specific block content type:

[SiteContentType(GUID = "67F617A4-2175-4360-975E-75EDF2B924A7",
        GroupName = SystemTabNames.Content)]
    [SiteImageUrl]
    [InlineBlockEditSettings(ShowNameProperty = true)]
    public class EditorialBlock : SiteBlockData
    {
        [Display(GroupName = SystemTabNames.Content)]
        [CultureSpecific]
        public virtual XhtmlString MainBody { get; set; }
    }

And below is to display Name and Categories properties and Settings group:``

[SiteContentType(GUID = "9E7F6DF5-A963-40C4-8683-211C4FA48AE1")]
    [SiteImageUrl]
    [InlineBlockEditSettings(ShowNameProperty = true, ShowCategoryProperty = true, HiddenGroups = "")]
    public class AdvancedBlock : SiteBlockData
    {
        [Display(Order = 1, GroupName = SystemTabNames.Content)]
        public virtual string Text1 { get; set; }
    
        [Display(Order = 2, GroupName = SystemTabNames.Content)]
        public virtual string Text2 { get; set; }
    
        [Display(Order = 1, GroupName = Global.GroupNames.Products)]
        public virtual string Text3 { get; set; }
    
        [Display(Order = 2, GroupName = Global.GroupNames.Products)]
        public virtual string Text4 { get; set; }
    }

To hide more than one group:

[SiteContentType(GUID = "9E7F6DF5-A963-40C4-8683-211C4FA48AE1")]
    [SiteImageUrl]
    [InlineBlockEditSettings(HiddenGroups = "Advanced, Contact")]
    public class AdvancedBlock : SiteBlockData
    {
        [Display(Order = 1, GroupName = SystemTabNames.Content)]
        public virtual string Text1 { get; set; }
    
        [Display(Order = 2, GroupName = SystemTabNames.Content)]
        public virtual string Text2 { get; set; }
    
        [Display(Order = 1, GroupName = Global.GroupNames.Products)]
        public virtual string Text3 { get; set; }
    
        [Display(Order = 2, GroupName = Global.GroupNames.Contact)]
        public virtual string Text4 { get; set; }
    }

Change settings for multiple block content types

If you want to show Name for several block content types, you can configure the setting in their base class, like this:

[InlineBlockEditSettings(ShowNameProperty = true)]
    public abstract class SiteBlockData : EPiServer.Core.BlockData
    {}
    
    [SiteContentType(GUID = "9E7F6DF5-A963-40C4-8683-211C4FA48AE1")]
    [SiteImageUrl]
    public class AdvancedBlock : SiteBlockData
    {
        [Display(Order = 1, GroupName = SystemTabNames.Content)]
        public virtual string Text1 { get; set; }
    
        [Display(Order = 2, GroupName = SystemTabNames.Content)]
        public virtual string Text2 { get; set; }
    
        [Display(Order = 1, GroupName = Global.GroupNames.Products)]
        public virtual string Text3 { get; set; }
    
        [Display(Order = 2, GroupName = Global.GroupNames.Contact)]
        public virtual string Text4 { get; set; }
    }

📘

Note

If you want to change a setting in a child block type, while still wanting to have some other settings from the base class, you have to copy those settings to the child block type class because the settings in the child block type override the settings in the base class.

Override auto-generated name for inline-creating blocks

Because the Name property is hidden by default, blocks created from an inline edit dialog (which is inline create) get an automatically generated name. The name is generated using ILocalAssetNameGenerator, and the default format is PageName BlockType AutoIncrementId.

To override the default auto-generated name format, you just need to implement ILocalAssetNameGenerator.


Did this page help you?