November Happy Hour will be moved to Thursday December 5th.

Detect if "Save & Publish" is clicked

Vote:
 

Hello

I wonder, when an editor click "Save & Publish" can I detect this click-event in code behind for current page?

I know that I can override methods like OnSave and OnCreate but I cant use these becasue I have a synch-jobb that creates some pages programaticly so I have to distinguish if an editor is clicking on "Save & Publish" or not. I neither can use delegates (global.asax) for Page events :(

Is it possible to detect this click? Would be glad if someone could help me poinitng me in right direction with some code or relevant links.

Thanks in advance!

#49957
Apr 06, 2011 16:50
Vote:
 
#49960
Apr 06, 2011 19:56
Vote:
 

How do you mean you can't use delegates? Why? So you can't intercept the actual save/publish of the page rather than the "click"? Like DataFactory's PublishingPage / PublishedPage?

#49961
Apr 06, 2011 20:00
Vote:
 

You could always hook into the Published event and then check the user who published the page? I assume you job runs as a specific user so if anyone else is the user then you know they have clicked "Save and Publish"?

The following code will allow you to hook into the published page event:

 

DataFactory.Instance.PublishedPage += Instance_PublishedPage;
        

void Instance_PublishedPage(object sender, PageEventArgs e)
{
         
}

    

#49962
Apr 06, 2011 20:01
Vote:
 

Hello

Thanks for your answers

Magnus:

If I use delegates I will hook up on the 'DataFactory.Instance.PublishedPage' as David says but I cant distinguish if it's the synch job or if current event is triggered by an editor clicking "Save & Publish". Why I have to separate these two is because different actions must occur.

if(synch)

{

 defult settings

}

else

{

  overrideing settings

}.

 

David:

Thank you, yes I have thought of this but.... we are using AD and I thought that I could control which AD group current user is a member of but a member that can synchronize can also be member of a group that not is able to synchronize so this is not bullet proof.

Thats why I wonder if there is a way to find out if an editor has clicked on "Save & Publish"

Thanks for helping me!

#49963
Apr 06, 2011 20:28
Vote:
 

this code will do the trick

    public class AttachEvents : EPiServer.PlugIn.PlugInAttribute
    {
        public static void Start()
        {            
           EPiServer.DataFactory.Instance.PublishingPage += new EPiServer.PageEventHandler(Instance_PublishingPage);
        }

        private static void Instance_PublishingPage(object sender, PageEventArgs e)
        {
            if (e.RequiredAccess == EPiServer.Security.AccessLevel.NoAccess)
                return;
            
            if (HttpContext.Current != null && 
                HttpContext.Current.Request.RawUrl.Contains("EditPanel.aspx"))
            {
//Save and publish                
            }
            }
        }
       
    }

    

#49964
Edited, Apr 06, 2011 21:37
Vote:
 

Thanks!  I'll try this out :D

 

#49969
Apr 07, 2011 8:28
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.