Created
January 18, 2022 09:19
-
-
Save prjseal/2748f369ca659be5ff1fc9b8db992440 to your computer and use it in GitHub Desktop.
Hide Properties in Umbraco 8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq; | |
using Umbraco.Core; | |
using Umbraco.Core.Composing; | |
using Umbraco.Web.Editors; | |
namespace CodeShare.Core.Composing | |
{ | |
[RuntimeLevel(MinLevel = RuntimeLevel.Run)] | |
public class EditorModelEventsComposer : ComponentComposer<EditorModelEventsComponent> | |
{ | |
} | |
public class EditorModelEventsComponent : IComponent | |
{ | |
public void Initialize() | |
{ | |
EditorModelEventManager.SendingContentModel += EditorModelEventManager_SendingContentModel; | |
} | |
public void Terminate() | |
{ | |
EditorModelEventManager.SendingContentModel -= EditorModelEventManager_SendingContentModel; | |
} | |
private void EditorModelEventManager_SendingContentModel(System.Web.Http.Filters.HttpActionExecutedContext sender, EditorModelEventArgs<Umbraco.Web.Models.ContentEditing.ContentItemDisplay> e) | |
{ | |
if (e.Model.ContentTypeAlias != "pageTypeAlias") return; | |
foreach (var variant in e.Model.Variants) | |
{ | |
foreach (var tab in variant.Tabs) | |
{ | |
tab.Properties = tab.Properties.Where(x => x.Alias != "propertyAlias"); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment