Display warning message in edit mode

Vote:
 

During releases, we want to prevent editors from publishing anything for a short period, in order to prevent loss of data (the EPiServer database is replicated between environments).

We have accomplished this attaching to the event DataFactory.Instance.PublishedPage in Global.asax, and in our attached method checking the status of a flag in our database. If the flag is raised, we simply set "e.CancelAction = true" and provide a custom message in "e.CancelReason". All ok so far.

However, in addition to this, we would like to notify the editors that publishing has been disabled as soon as they enter edit mode for an article, to discourage them from doing any work on the content at all (after all, it can't be published anyway). In CMS 4.62, this was easily accomplished by attaching to "Global.EditPageValidators" in Global.asax, like this: Global.EditPageValidators += new PageValidateEventHandler(Global_EditPageValidators); Then, in our attached method, we would set "e.IsValid=false" and provide a custom warning message to "e.ErrorMessage" if the flag in our database was raised.

However, I cannot for the life of me figure out how to accomplish the same thing in CMS 5 R2! It's probably a simple thing, once you know what to attach where, but I'm getting lost in the SDK..

Any help would be much appreciated! :-)

-b

#46200
Dec 01, 2010 18:58
Vote:
 

Hi!

You can probably attach to the EPiServer.UI.Edit.EditPanel.LoadedPage event where you will get a refrence to the EditPanel instance:

public delegate void LoadedPageEventHandler(EditPanel sender, LoadedPageEventArgs e);

Here you should be able to check your flag and as some sort of a message to the editor.

Regards
Linus Ekström
EPiServer Development Team

#46203
Dec 02, 2010 7:29
Vote:
 

Excellent, that was the event I was looking for. However, I still cannot figure out how to add a warning message to the top of the page. I have searched and searched, and I have found another post which asks the same (http://world.episerver.com/Templates/Forum/Pages/thread.aspx?id=31239), but no answers.

Any suggestions?

#46209
Dec 02, 2010 10:21
Vote:
 

Hi!

There does not seem to be any public method to add warning messages but you can achieve this by adding a static validator:

void EditPanel_LoadedPage(EPiServer.UI.Edit.EditPanel sender, EPiServer.UI.Edit.LoadedPageEventArgs e)
{
    sender.Validators.Add(new StaticValidator("Some error message"));
}

/Linus

#46214
Dec 02, 2010 10:35
Vote:
 

One dirty way of doing it is to look at this on page 25

http://www.slideshare.net/EPiServerMeetupOslo/episerver-behind-the-scene

#46215
Dec 02, 2010 11:28
Vote:
 

Excellent, thank you very much.

I tried Linus' suggestion, and it works like a charm - just what I needed :-)

#46217
Dec 02, 2010 12:10