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.
|<processor patch:before="*" type="MyProject.CMS.Custom.Pipelines.RenderField.ShowTitleWhenBlank, MyProject.CMS.Custom" />|
|public class ShowTitleWhenBlank|
|public void Process(RenderFieldArgs args)|
|args.RenderParameters["show-title-when-blank"] = "true";|
That’s it! Great find Neil!