I've found several threads regarding some of the stuff I need to do but I haven't quite managed to get the whole picture and a strategy for making this work. Ergo this post.
What I need to do:
Intercept Save Event
Do a check on ContentType of node beeing saved
If ContentType in question: Display a confirmation dialog "Are you sure you wan't to save this..."
If user confirms: just save, if not: cancel saving
If NOT ContentType in Question, save content as normal
Bullet 1. and 2. I have managed to get working by creating a ContentEventHandler extending ApplicationEventHandler:
public class ContentEventHandler : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
//register the event listener:
ContentService.Saving += ContentService_Saving;
}
private void ContentService_Saving(IContentService sender, SaveEventArgs
Bullet 3. I'm not sure how I should go about achieving. I've read some posts stating that you could register a javascript with the Page, and others stating that you can use the DialogService, showing Angular code. However I have a feeling that one should create a custom view and "register" this with the save event somehow similar to what one does when f.ex creating a custom MenuItem:
var i = new MenuItem("someMenuItem", "Some Menu Item");
i.AdditionalData.Add("actionView", "/App_Plugins/MyPlugin/someMenuItem.html");
e.Menu.Items.Add(i);
Bullet 4 I guess is dependent on the solution of bullet 3..
As for bullet 5 I have managed to call the SaveAndPublishWithStatus() method. But is this actually necessary? Because by saving the content, my custom save event is triggered a second time. I guess I could put something on Session saying that we are now saving "manually", but I need some way of just skipping my code and going directly to the base. Would wrapping all of my event code make the original save function beeing called?
Intercept Save event and show confirmation dialog
Hi.
I've found several threads regarding some of the stuff I need to do but I haven't quite managed to get the whole picture and a strategy for making this work. Ergo this post.
What I need to do:
Bullet 1. and 2. I have managed to get working by creating a ContentEventHandler extending ApplicationEventHandler:
Bullet 3. I'm not sure how I should go about achieving. I've read some posts stating that you could register a javascript with the Page, and others stating that you can use the DialogService, showing Angular code. However I have a feeling that one should create a custom view and "register" this with the save event somehow similar to what one does when f.ex creating a custom MenuItem:
Bullet 4 I guess is dependent on the solution of bullet 3..
As for bullet 5 I have managed to call the SaveAndPublishWithStatus() method. But is this actually necessary? Because by saving the content, my custom save event is triggered a second time. I guess I could put something on Session saying that we are now saving "manually", but I need some way of just skipping my code and going directly to the base. Would wrapping all of my event code make the original save function beeing called?
Maybe I'm missing something here...
I have found Matt Brailsford's post on Tweaking Umbraco 7 Back Office.
The Tweaking Views section describes how you can register an alternative edit GUI by using http interceptors.
This would make me able to override what happens when you click the Save and Publish button.
I was hoping there was a way which didn't involve modifying core files but probably there isn't.
is working on a reply...