Hey Brandon,
For the Quick Edit you can configure what you're asking for by adding the InlineBlockEditSettings
attribute to your blocks (or base block for reuse). Then set the HiddenGroups
parameter to include your custom content group name.
[InlineBlockEditSettings(HiddenGroups = "Advanced, MyCustomGroup")]
public class AdvancedBlock : SiteBlockData
Check out this section of the documentation for more details:
https://world.optimizely.com/documentation/developer-guides/CMS/Content/inline-edit-settings/
Property | Default value | Description |
ShowNameProperty | false | When true , then Name property will be displayed |
ShowCategoryProperty | false | When true , then Categories property will be displayed |
HiddenGroups | Advanced | Comma-separated list of tabs that should be hidden |
So that only works for the Quick Edit (Inline Editing) form, but doesn't seem to affect the 'Create a new block' form in a Content Area.
My observation is that any properties in the 'Settings' (Advanced) tab doesn't appear in either forms. Any idea how I can remove a property from the Create New block form as well.
You can hide properties from the 'create' view by using a meta data extender. It's a bit more complicated but I cannot think of better way to do it — the implementation is described below. It somewhat replicates how the settings are hidden.
I mostly used the information in this post and tweaked it to hide the group instead: https://www.david-tec.com/2017/07/hiding-required-properties-on-the-create-new-page-in-episerver/
This meta data extender will hide any properties in the group 'MyCustomGroup':
public class HideOnContentCreateMetadataExtender : IMetadataExtender
{
public void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
{
// When content is being created the content link is 0
if (metadata.Model is IContent data && data.ContentLink.ID == 0)
{
foreach (var modelMetadata in metadata.Properties)
{
var property = (ExtendedMetadata)modelMetadata;
//Hide my custom group
if (property.GroupName == "MyCustomGroup")
{
property.ShowForEdit = false;
//If property if required you won't be able to create the content, so set IsRequired = false
if (property.IsRequired)
property.IsRequired = false;
}
}
}
}
}
Register the meta data extender in an initialization module:
[ModuleDependency(typeof(InitializationModule))]
public class MetadataHandlerInitialization : IInitializableModule
{
public void Initialize(InitializationEngine context)
{
var registry = context.Locate.Advanced.GetInstance<MetadataHandlerRegistry>();
registry.RegisterMetadataHandler(typeof(ContentData), new HideOnContentCreateMetadataExtender());
}
public void Uninitialize(InitializationEngine context){ }
}
We noticed that any properties that are found under SystemTabNames.Settings do not appear in the Quick Edit and Record Creation forms.
Is there a way to have custom Tab Names use the same behavior? This would help us in keeping those two forms more clean.
--OR--
Is there another way to keep properties from appearing in the Quick Edit and Record Creation forms?