November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Have a look at Geta.Optimizely.Categories repo they have an example here on how it can be achieved using an editor descriptor. I tested on a CMS12 site and looks to work
/// <summary>
/// Hides the categories drop down list for types where it is not needed
/// </summary>
[EditorDescriptorRegistration(TargetType = typeof(CategoryList), EditorDescriptorBehavior = EditorDescriptorBehavior.Default)]
public class HideCategoryEditorDescriptor : EditorDescriptor
{
public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
{
base.ModifyMetadata(metadata, attributes);
if (metadata.PropertyName == "icategorizable_category")
{
metadata.ShowForEdit = false;
}
}
}
Thanks. I tried it in an Alloy solution here, and it works there. So I guess it must be something in our solution that is causing it not to work.
ScaffoldColumn(false) seems to work on custom made properties but not on Optimizely native ones ie Category. Following code will work on all properties. This will keep the functionality as it was in Epi11.
[ModuleDependency(
typeof(InitializationModule)
)]
public class SiteMetadataExtenderInitialization : IInitializableModule
{
public void Initialize(InitializationEngine context)
{
if (context.HostType == HostType.WebApplication)
{
var registry = context.Locate.Advanced.GetInstance<MetadataHandlerRegistry>();
registry.RegisterMetadataHandler(typeof(ContentData), new SiteMetadataExtender());
}
}
public void Uninitialize(InitializationEngine context)
{
}
}
public class SiteMetadataExtender : IMetadataExtender
{
public void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
{
foreach (ExtendedMetadata property in metadata.Properties)
{
foreach (var attribute in property.Attributes)
{
if (attribute is ScaffoldColumnAttribute s)
{
if (s.Scaffold == false)
{
property.ShowForEdit = false;
}
}
}
}
}
}
And on the property
[ScaffoldColumn(false)]
public virtual CategoryList Category { get; set; }
I managed to solve it like this:
[EditorDescriptorRegistration(TargetType = typeof(CategoryList), EditorDescriptorBehavior = EditorDescriptorBehavior.Default)]
public class CategoryEditorDescriptor : EditorDescriptor
{
public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
{
base.ModifyMetadata(metadata, attributes);
if (metadata.PropertyName == "icategorizable_category")
{
metadata.ShowForEdit = false;
}
}
}
Hi!
Does anyone know how to hide the default category property in Optimizely 12? The editor descriptor with the scaffold attribute works in older versions, but it doesn't seem to work in version 12.