Accessing IPublishedContent in ContentService.Published event
Hi All,
Hoping you can help/point me in the right direction.
I'm hooking into the ContentService.Published event but I'm trying to access the IPublishedContent equivalents of the IContent.
I have the following:
if(args.PublishedEntities != null)
{
foreach(var publishedEntity in args.PublishedEntities)
{
//I want to do some bits here
}
}
What I'm trying to do is much easier if I can get the IPublishedContent for my IContent, however when I try and use an instance of UmbracoHelper to do .TypedContent passing in the key from the IContent it is returning null.
If I cannot get the IPublishedContent from IContent, what is the best way to find the root node of an IContent and also handle children and property access?
Steven mentioned the following in Slack:
umbraco.content.AfterUpdateDocumentCache
however this doesn't seem to fire after the cache has been updated in that the IPublishedContent still doesn't come back from TypedContent and looking at the umbraco.config file it's still missing the newly published entry.
Accessing IPublishedContent in ContentService.Published event
Hi All,
Hoping you can help/point me in the right direction. I'm hooking into the ContentService.Published event but I'm trying to access the IPublishedContent equivalents of the IContent.
I have the following:
What I'm trying to do is much easier if I can get the IPublishedContent for my IContent, however when I try and use an instance of UmbracoHelper to do .TypedContent passing in the key from the IContent it is returning null.
If I cannot get the IPublishedContent from IContent, what is the best way to find the root node of an IContent and also handle children and property access?
Steven mentioned the following in Slack:
however this doesn't seem to fire after the cache has been updated in that the IPublishedContent still doesn't come back from TypedContent and looking at the umbraco.config file it's still missing the newly published entry.
Has anyone got any ideas that can help?
Cheers,
Nik
try this:
var content = UmbracoContext.Current.ContentCache.GetById(publishedEntity .Id);
Thanks Marcio, that seems to be the way to get it. You're a star, thanks!
is working on a reply...