Sitecore 6 introduces a number of new pipelines. Some reflect new features added to the system, and some provide new customization opportunities for the previously existing features.
Today's topic is the getContentEditorWarnings pipeline.
Content Editor warnings are the yellow warning blocks that appear above sections and fields in the main Content Editor area. We have more than a dozen warnings supported out of the box, such as "the item is protected", "the item will not be published", etc.
These warnings are specific to Sitecore - we don't know anything about the business domain of the site. However it is easy to add new warnings using the getContentEditorPipeline.
As an example, I've created a warning that checks the updated date of the item, and warns if the item haven't been updated in 6 months or more:
public class GetContentEditorWarnings { public void Process(GetContentEditorWarningsArgs args) { if (DateTime.Now - args.Item.Statistics.Updated > TimeSpan.FromDays(180)) { var warning = args.Add(); warning.Title = "This item haven't been updated in a while"; warning.Text = "Consider revising the content."; warning.AddOption("Set a reminder", "item:reminderset(id={0})".FormatWith(args.Item.ID)); } } }
The steps here a simple: title and text provide warning description to the user, and AddOptions allows setting up quick fixes. In this example, a “set a reminder” dialog will popup if “Set a reminder” is clicked.
To enable the warning, just add the new processor to the getContentEditorWarnings pipeline either by modifying web.config or using auto-include files (recommended).<getContentEditorWarnings> .. <processor type="Pipelines.ContentEditor.GetContentEditorWarnings, Pipelines" /></getContentEditorWarnings>
A warning can also be exclusive or fullscreen. Exclusive warnings do not allow other warnings to appear. If no exclusive warning is displayed, multiple “normal” warnings can be shown. If fullscreen warning is shown, it hides the usual editing interface of the Content Editor – sections and fields are hidden. Both warning modes can be activated by setting relevant properties of the GetContentEditorWarningsArgs.
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.