Skip to content

Instantly share code, notes, and snippets.

@JRondeau16
Created July 28, 2017 19:39
Show Gist options
  • Save JRondeau16/50fd201845f3f8319a4e84434b254ac4 to your computer and use it in GitHub Desktop.
Save JRondeau16/50fd201845f3f8319a4e84434b254ac4 to your computer and use it in GitHub Desktop.
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