Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get Fields Pipeline Override
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