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.
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.
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 :-)
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:
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
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
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
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
is working on a reply...