With the Experience Editor being such an important aspect of content management, developers are constantly looking for ways to guide the content author. One way is to provide pointed messaging within the editor itself. Hence Editor Messages. Just create a helper extension method as follows:
The enum is used to toggle the class between three different message types, Info, Warning and Error. Create the desired CSS for each and use your extension method as follows:
@Html.EditorMessage("Here is INFO text.", EditorMessageType.Info)
@Html.EditorMessage("Here is WARNING text.", EditorMessageType.Waring)
@Html.EditorMessage("Here is ERROR text.", EditorMessageType.Error)
and you should see something like:
Now you can supply useful editor messages with just a few lines of code.
NOTE:If you pull in the Rendering Context, you could convert your editor messages to links and do fun things like link to Preview or an item in the Content Editor. Hope someone finds this tidbit useful.
15+ year programming professional with 10+ years devoted to Sitecore development. I've been using the platform since Sitecore 6.0 and currently serve as a Technical Architect at Verndale.