You should be able to get it working with ApplicationEventHandler and the "Published" event from the contentService. This is working code in a v7 website we have:
public class DateFolderEvents : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
Umbraco.Core.Services.ContentService.Published += ContentService_Published;
base.ApplicationStarted(umbracoApplication, applicationContext);
}
private void ContentService_Published(Core.Publishing.IPublishingStrategy sender, Core.Events.PublishEventArgs<Core.Models.IContent> e)
{
foreach (var content in e.PublishedEntities)
{
PublishDoc(content);
}
}
private void PublishDoc(IContent sender)
{
var user = new User(sender.CreatorId);
// do your stuff
}
}
ApplicationBase events - V 7.0.3
Hi,
I am trying to attach the following events but couldnt get it working.
Document.New
and
Document.BeforePublish
Tried with ApplicationBase, ApplicationStartupHandler and IApplicationEventHandler but none of it worked.
Can anyone please provide the correct way for this in Umbraco 7.
Thanks in advance
Hi,
You should be able to get it working with ApplicationEventHandler and the "Published" event from the contentService. This is working code in a v7 website we have:
For others working with Umbraco 8 you can see this link: https://our.umbraco.com/documentation/reference/events/application-startup
Thanks a lot Damiaan.. It worked like a charm :)
Don't forget to mark the reply as answer. It's not because we are friendly, we don't like karma ;-)
is working on a reply...