Created
July 28, 2017 19:39
-
-
Save JRondeau16/50fd201845f3f8319a4e84434b254ac4 to your computer and use it in GitHub Desktop.
Get Fields Pipeline Override
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 Elision.Foundation.Kernel; | |
using Sitecore.Data.Fields; | |
using Sitecore.Data.Templates; | |
namespace Elision.Foundation.FieldVisibility.Pipelines.GetContentEditorFields | |
{ | |
public class GetFields : Sitecore.Shell.Applications.ContentEditor.Pipelines.GetContentEditorFields.GetFields | |
{ | |
protected override bool CanShowField(Field field, TemplateField templateField) | |
{ | |
if (ShowDataFieldsOnly) | |
{ | |
var templateFieldItem = field.Database.GetItem(templateField.ID); | |
//Get the value of the checkbox field you added. I used generated code via TDS. | |
var hideWithStandardFields = | |
(templateFieldItem?.Fields[Templates.Template_Field.FieldIds.HideWithStandardFields] != null | |
&& templateFieldItem.Fields[Templates.Template_Field.FieldIds.HideWithStandardFields].Value == "1"); | |
if (hideWithStandardFields) | |
return false; | |
} | |
return base.CanShowField(field, templateField); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment