How to Check the Current Page is Newest

Vote:
 

I want to call a function if current page is newly created. and if it is already created then i want to call someother function. Can anyone help to get ridd off by this situation. Thanks !

#112329
Oct 28, 2014 9:27
Vote:
 

Hi,


What do you mean by "newly created"?

#112454
Oct 28, 2014 14:27
Vote:
 

Hi,

If I understand you correctly, you want to listen to content events and do something when a page is created or when a page is updated. You can do that by listening to events in either Global.asax or an initializable module.

protected void Application_Start(object sender, EventArgs e)
{
    var events = ServiceLocator.Current.GetInstance<IContentEvents>();
    events.CreatedContent += CreatedContent;
    events.SavedContent += SavedContent;
}

void CreatedContent(object sender, ContentEventArgs e)
{
            
}

void SavedContent(object sender, ContentEventArgs e)
{
#112473
Oct 28, 2014 18:57
Vote:
 

Oh sorry, my code was for EPiServer 7 and not 6. This will work in 6:

protected void Application_Start(object sender, EventArgs e)
{
    DataFactory.Instance.CreatedPage += CreatedPage;
    DataFactory.Instance.SavedPage += SavedPage;
}

void CreatedPage(object sender, PageEventArgs e)
{
            
}

void SavedPage(object sender, PageEventArgs e)
{

}
#112474
Oct 28, 2014 19:00
Vote:
 

Thank you Johan Petersson :-)

#112479
Oct 29, 2014 6:26
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.