1

How to prevent the Sitecore Content Editor to toggling the standard field checkbox.

so that when they are trying to inadvertently modify things that they can't able to change the important settings or the value of the standard fields.

It should be disabled for all users except for administrators.

2

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.

enter image description here

| improve this answer | |
  • Note that the QueryState part can be reduced to return Sitecore.Context.User.IsAdministrator ? CommandState.Enabled : CommandState.Disabled – Sebastian Lay Jul 30 '19 at 16:29
2

If you are specific to disable the standard field checkbox then your solution looks good but if you want to hide it you can easily do it using OOTB Security Editor. Create a denied role for the standard field in core database -/sitecore/content/Applications/Content Editor/Ribbons/Chunks/View/Standard Fields and assign it to the user or for all the content editor assign it "Sitecore Client Authoring" or "Sitecore/Everyone" role.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.