Copied to clipboard

Flag this post as spam?

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


  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Mar 13, 2013 @ 21:41
    Bo Damgaard Mortensen
    0

    PublishingStrategy.Published event not being hit in v6

    Hi all,

    Currently trying to get my head around the new API in Umbraco v. 6 (actually it is running 6.0.0) I need to hook up on the Published event and run some logic from there.

    What I have so far is:

    public class ContentEvents : IApplicationEventHandler
        {
    
            public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
            {            
            }
    
            public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
            {
                PublishingStrategy.Published += PublishingStrategy_Published;
            }
    
    void PublishingStrategy_Published(IPublishingStrategy sender, Umbraco.Core.Events.PublishEventArgs<Umbraco.Core.Models.IContent> e)
            {
                foreach(var entity in e.PublishedEntities)
                {
                     // My logic here
                }
            }
    }

    However, the event is never being hit when I publish a document in Umbraco. Tried placing a breakpoint there, but it's not hit aswell.

    Have I missed something here? :-)

    Thanks in advance!

    All the best,

    Bo

  • gary 385 posts 916 karma points
    Mar 13, 2013 @ 22:25
    gary
    0

    Hi Bo

    There are a couple of bugs surrounding save and publish events, http://issues.umbraco.org/issue/U4-547 think this one may be in the same area as you are looking.

     

    Hope it helps saves you some time G

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Mar 13, 2013 @ 22:38
    Bo Damgaard Mortensen
    0

    Hi Gary,

    Thanks a lot :-) I suspected it could be that it was a bug, but wouldn't negate that it could be a mistake from me aswell.

    I solved it for now by hooking up on the Document.AfterPublish event and then getting a reference to the Content object by id. Not a very elegant solution though, but it has to do for now until bugs (if any..) has been fixed :-)

    - Bo

  • gary 385 posts 916 karma points
    Mar 13, 2013 @ 22:47
    gary
    0

    Hi Bo

    Happy to help. Have spent many hours beating myself up trying to find solutions for the wrong problem.

    Maybe if everything was perfect we wouldn't have such a great community?

    Regards G

Please Sign in or register to post replies

Write your reply to:

Draft