When using the "Published" event in v6 you will have to assume that the actually publishing (refreshing the xml cache etc) is done in the background and not necessarily finished when hitting your AfterPublish event. But at the same time its also safe to assume that the Content objects in the PublishedEntities collection corresponds to the published items (be it INode, IPublishedContent or DynamicContent). So you might as well get the title from the content you are iterating as that same content is the basis of you published content. The following will give you the same result, so no need to fetch it from the cached/published nodes:
voidContentService_Published(Umbraco.Core.Publishing.IPublishingStrategy sender,Umbraco.Core.Events.PublishEventArgs<Umbraco.Core.Models.IContent> e) { foreach(var content in e.PublishedEntities) { var newTitel = content.GetValue<string>("title"); } }
thanks for your reply. That was indeed the assumption I made; I must have missed it in the documentation of the V6-API ;). Now it works (although my code was a bit more complex than the above code).
Published event in V6 vs Document_AfterPublish
Hi,
I was trying to update some code to V6 and I ran into the triggering of events. In v4 I had the following code:
And this will return the new "titel" of the node that I just published.
When I try to do the same in V6 it will return the old "titel"
Am I doing anything wrong, is it the wrong event to trigger or do I overlook something?
Hope somebody could help me out!
Greetings Jeffrey
Nobody?
When using the "Published" event in v6 you will have to assume that the actually publishing (refreshing the xml cache etc) is done in the background and not necessarily finished when hitting your AfterPublish event. But at the same time its also safe to assume that the Content objects in the PublishedEntities collection corresponds to the published items (be it INode, IPublishedContent or DynamicContent). So you might as well get the title from the content you are iterating as that same content is the basis of you published content. The following will give you the same result, so no need to fetch it from the cached/published nodes:
Hope this helps,
Morten
Hi Morten,
thanks for your reply. That was indeed the assumption I made; I must have missed it in the documentation of the V6-API ;). Now it works (although my code was a bit more complex than the above code).
Greetings, Jeffrey
is working on a reply...