AI OnAI Off
Did you look at the solution inside this post ? https://world.episerver.com/forum/developer-forum/-Episerver-75-CMS/Thread-Container/2019/7/hide-tab-from-specific-page-type/
https://gregwiechec.com/2018/03/hide-tabs-and-properties-in-edit-mode/ would be your best bet. Create an ILayoutVisibilityResolver class and then appy it to the Tab/Properties as needed
Thanks for your responses. I had seen the blog posts that you both posted which I had tried. But I revisited my code. Here is the new code which seems to work just fine:
[EditorDescriptorRegistration(TargetType = typeof(EPiServer.Core.ContentData))]
public class SiteMetadataExtender : EditorDescriptor
{
public override void ModifyMetadata(ExtendedMetadata metadata, System.Collections.Generic.IEnumerable<System.Attribute> attributes)
{
List<string> groupsToHide = new List<string> { "Tab1", "Tab2", "Tab3", "Tab4" };
if (SiteDefinition.Current.Name == "Site1" || SiteDefinition.Current.Name == "Site2")
{
foreach (EPiServer.Shell.ObjectEditing.ExtendedMetadata property in metadata.Properties)
{
if (property.GroupName != null && groupsToHide.Contains(property.GroupName) && property.GroupSettings != null)
{
property.GroupSettings.DisplayUI = false;
}
}
}
}
}
When editing EPiServer property pages, I want to hide certain tabs for a page depending upon the site. I found a snippet of code on the web which looks like the following (I've modified it slightly to suit my needs):
This code gets fired when I open a property page, however through most iterations, property.GroupSettings is null and I am not seeing my custom tabs enumerated.
Does anyone know how to fix this? Is this even the proper code to handle this scenario?
Thanks.