Showing some standard fields
We developers are accustomed to work in a content tree and seeing all the Standard fields. In the past if a Content Editor needs to have access to those sections, we just checked set the Standard fields in the View tab.
The drawback is that all sections of the Standard fields are suddenly visible. Which makes the editor overwhelming to say at least.
A regular Content Editor shouldn't have to mess around in all those Standard Fields.
In a particular case I was working on today I wanted the Content Editors to be able to configure the access rights on documents in the media library. But directly in the Content Tree and not by using the Security Editor.
There is a way to do this and I have to thank Alistair Denys because he wrote an article about it in 2008. Thats 8 years ago... I didn't even know Sitecore existed back then!
I tried it and this still works in Sitecore 8.1.
Here is the link to the article and if you're not following him twitter, you should!
The magic all happens in the existing GetContentEditorFields.GetFields pipeline which you can extend to your liking!
using Sitecore.Shell.Applications.ContentEditor.Pipelines.GetContentEditorFields;
namespace MyProject.Pipelines
{
public class CustomGetFields : GetFields
{
protected override bool CanShowField(Sitecore.Data.Fields.Field field, Sitecore.Data.Templates.TemplateField templateField)
{
//Here you can change which field(s) must be visible by default.
if (field.ID == Sitecore.FieldIDs.Security)
return true;
return base.CanShowField(field, templateField);
}
}
}
And here is the patch file you need to add to your App_Config folder:
<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<getContentEditorFields>
<processor type="Sitecore.Shell.Applications.ContentEditor.Pipelines.GetContentEditorFields.GetFields, Sitecore.Client">
<patch:attribute name="type">MyProject.Pipelines.CustomGetFields, MyProject.Pipelines</patch:attribute>
</processor>
</getContentEditorFields>
</sitecore>
</configuration>
You can also do something more fancy by only showing the field to users in a certain role. Here I've added the check on the "sitecore\Sitecore Client Authoring" role.
using Sitecore.Shell.Applications.ContentEditor.Pipelines.GetContentEditorFields;
namespace Watergroep.Pipelines
{
public class CustomGetFields : GetFields
{
protected override bool CanShowField(Sitecore.Data.Fields.Field field, Sitecore.Data.Templates.TemplateField templateField)
{
if (field.ID == Sitecore.FieldIDs.Security
&& Sitecore.Context.User.IsInRole("sitecore\\Sitecore Client Authoring"))
return true;
return base.CanShowField(field, templateField);
}
}
}
And here is the result when logging in with a users that has the Sitecore Client Authoring role. They can now assign security by applying access rights.