A few weeks ago on Sitecore Slack chat, fellow MVP Neil Shack discovered a tucked away setting in the renderField
pipeline. Enabling this causes the field name to be rendered in the default placeholder text in Experience Editor mode:
It seems that this is an old feature from back in the XSLT days, but it seems to have been forgotten over time…
The show-title-when-blank attribute can be used to display the field name before the inline editing control in the Page Editor if the field is empty, which can help content authors locate empty fields.
Good news is we can still enable it! Patch in the code below.
Now when the GetDefaultText
method is called in Sitecore.Pipelines.RenderField.RenderWebEditing
it will prefix the placeholder text with the Display Name of the field (or fallback to the Field Name). This makes it much easier for the editors to see what fields are present and what they are about to edit.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> | |
<sitecore> | |
<pipelines> | |
<renderField> | |
<processor patch:before="*[1]" type="MyProject.CMS.Custom.Pipelines.RenderField.ShowTitleWhenBlank, MyProject.CMS.Custom" /> | |
</renderField> | |
</pipelines> | |
</sitecore> | |
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Sitecore.Pipelines.RenderField; | |
namespace MyProject.CMS.Custom.Pipelines.RenderField | |
{ | |
public class ShowTitleWhenBlank | |
{ | |
public void Process(RenderFieldArgs args) | |
{ | |
args.RenderParameters["show-title-when-blank"] = "true"; | |
} | |
} | |
} |
That’s it! Great find Neil!
Nice blog jammy.