Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Dirk Maes 6 posts 26 karma points
    Mar 31, 2014 @ 18:11
    Dirk Maes
    0

    v6.1.6 Eventhandler SendToPublish

    Hi, I have a general problem with the ApplicationEventHandler, as it doesn't seem to fire the event that I could use.

    I want execute some code and (bulk)save a couple of properties for every document when I Publish an entire tree at once in the CMS. So this has to happen before publishing, not after.

    This is how my custom eventhandler looks; does anyone know why these two events aren't working?

    Thanks!

    public class EventHandler : ApplicationEventHandler
        {
            protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
            {
                base.ApplicationStarted(umbracoApplication, applicationContext);
                ContentService.SendingToPublish += PublishingStrategy_Publishing;                  
                ContentService.SentToPublish += ContentService_SentToPublish;
    
                ContentService.Published += ContentService_Published;    
            }
        }
    
            void ContentService_Published(Umbraco.Core.Publishing.IPublishingStrategy sender, Umbraco.Core.Events.PublishEventArgs e)
            {
               //This guy works, but it's not what I need
            }
    
            void ContentService_SentToPublish(IContentService sender, Umbraco.Core.Events.SendToPublishEventArgs e)
            {
               //Never fires
            }
    
            void PublishingStrategy_Publishing(IContentService sender, Umbraco.Core.Events.SendToPublishEventArgs e)
            {
               //Never fires
            }
    
    
  • Dirk Maes 6 posts 26 karma points
    Apr 01, 2014 @ 13:35
    Dirk Maes
    0

    "solved it", by using the depricated Document.BeforePublish instead of the ContentService.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies