Hi there,
Today a very easy blog-post, but still a nice to know tip from my side.
I was working on some small functionality for news items. In my current project we have buckets full with news items and we're using a wildcard-page to render these out. Sometimes content editors want to quickly know what the url will be of a certain news item relative to the site. So I thought let's add a processor to the GetContentEditorWarnings pipeline for this.
So here's a default implementation
| 1 | public void Process(GetContentEditorWarningsArgs args) |
| 2 | { |
| 3 | var item = args.Item; |
| 4 | if (item == null) |
| 5 | return; |
| 6 | |
| 7 | var template = TemplateManager.GetTemplate(item); |
| 8 | |
| 9 | if (template.DescendsFromOrEquals(Constants.NewsTemplateId)) |
| 10 | { |
| 11 | var contentEditorWarning = args.Add(); |
| 12 | contentEditorWarning.Title = Translate.Text("The relative URL for this News is"); |
| 13 | contentEditorWarning.Text = NewsUtility.ConstructNewsUrl(item); |
| 14 | } |
| 15 | } |
By default it renders out as a 'yellow warning' with a 'warning icon'.

Since I didn't really like the fact that it's a 'Warning', but more _'Information'_for the content author, I investigated where that specific _'scWarning'_class is set that makes everything yellow. It turns out that is happening in the following class:
- Sitecore.Shell.Applications.ContentManager.Editor (in the Sitecore.Client dll)
In there there's the following logic
| 1 | private static string GetEditorWarningCss(string iconUrl) => !iconUrl.Contains("information") ? "scWarning" : "scInformation"; |
So as we can see when the icon contains 'information' it will change the class to 'scInformation', and that's just what I wanted. So when we now adjust out logic like this:
| 1 | public void Process(GetContentEditorWarningsArgs args) |
| 2 | { |
| 3 | var item = args.Item; |
| 4 | if (item == null) |
| 5 | return; |
| 6 | |
| 7 | var template = TemplateManager.GetTemplate(item); |
| 8 | |
| 9 | if (template.DescendsFromOrEquals(Constants.NewsTemplateId)) |
| 10 | { |
| 11 | var contentEditorWarning = args.Add(); |
| 12 | contentEditorWarning.Title = Translate.Text("The relative URL for this News is"); |
| 13 | contentEditorWarning.Text = NewsUtility.ConstructNewsUrl(item); |
| 14 | contentEditorWarning.Icon = "/sitecore/shell/themes/standard/Images/information.png"; |
| 15 | } |
| 16 | } |
The result of this that we get a nice blue 'Information' notification in the content editor of Sitecore.

And that's it. So simple 😉
Happy Sitecore-ing!
–Robbert








