The standard fields checkbox selecting from the view tab in sitecore instance ribbon, we see a collection of fields and their field groups that are used to contain configurable metadata about items in Sitecore.
These fields are very useful to configure things like help text, icons, workflow, publishing settings, etc. But sometimes it becomes very confusing for the non-technical sitecore user after viewing so many fields suddenly as soon as checking the checkbox for standard fields.
How to disable the Sitecore standard fields checkbox for non-admin users.
To do this I have extended the standard field checkbox button command which name is like contenteditor:togglestandardfields , in the showconfig.aspx and search for the above name, this will show you like below configuration line
<command name="contenteditor:togglestandardfields" type="Sitecore.Shell.Framework.Commands.ContentEditor.ToggleStandardFields,Sitecore.Kernel"/>
Now, instead of using Sitecore default command type I have written a small code and just put the type in the above command like below
<configuration xmlns:patch="www.sitecore.net/.../" xmlns:role="www.sitecore.net/.../">
<sitecore role:require="Standalone or ContentManagement">
<commands>
<command name="contenteditor:togglestandardfields"
type="Your Project Assembly Name.DisabledStandardField, Your Assembly Name "/>
</commands>
</sitecore>
</configuration>
Below is the DisabledStandardField code
/// <summary>Represents the Toggle Standard Fields command.</summary>
[Serializable]
public class DisabledStandardField : Sitecore.Shell.Framework.Commands.Command
{
/// <summary>Executes the command in the specified context.</summary>
/// <param name="context">The context.</param>
public override void Execute(CommandContext context)
{
}
/// <summary>Gets the click action.</summary>
/// <param name="context">The context.</param>
/// <param name="click">The default click action.</param>
/// <returns></returns>
public override string GetClick(CommandContext context, string click)
{
return "StandardFields_Click";
}
/// <summary>Queries the state of the command.</summary>
/// <param name="context">The context.</param>
/// <returns></returns>
public override CommandState QueryState(CommandContext context)
{
// if (Sitecore.Context.User.IsInRole("extranet\\Content Role"))
if (!Sitecore.Context.User.IsAdministrator)
return CommandState.Disabled;
return CommandState.Enabled;
}
}
So we can see if any user except for administrator visit the CM instance, they can't be to to click on the standard field check box.