Having issues with using the UmbracoHelper method TypedContent(id). After save and published event .
using ContentService_Published event I use the method TypedContent to obtain the current published node. But it is null on first attempt. Only if you publish twice , on the second attempt of publishing the node, does it return a node. Has anyone else got this issue. on the latest umbraco 7.1.6
Yes, the cache is not updated until after the publish event, so you cannot get the new Published Content form TypedContent immediately.
There is a legacy event you can use which occurs after the cache has been updated. Details in this post and also there is a new event CacheUpdated which you can find out about here
public class CountryAfterCacheUpdated : ApplicationEventHandler
{
public CountryAfterCacheUpdated()
{
CacheRefresherBase
public void PublishedPageCacheRefresherCacheUpdated(PageCacheRefresher sender, CacheRefresherEventArgs e)
{
switch (e.MessageType)
{
case MessageType.RefreshByInstance:
var contentToAdd = e.MessageObject as IContent;
//check the alias that it is the right type
if (contentToAdd != null && contentToAdd.ContentType.Alias == CountryDocument.CountryNodeTypeAlias)
{
//logic to add content
}
break;
case MessageType.RemoveByInstance:
var contentToRemove = e.MessageObject as IContent;
//check the alias that it is the right type
if (contentToRemove != null && contentToRemove.ContentType.Alias == CountryDocument.CountryNodeTypeAlias)
{
//logic to remove content
}
break;
default:
//We don't support these, these message types will not fire for unpublished content
break;
}
}
}
The event for removing and adding worked perfectly
UmbracoHelper TypedContent?
Having issues with using the UmbracoHelper method TypedContent(id). After save and published event .
using ContentService_Published event I use the method TypedContent to obtain the current published node. But it is null on first attempt. Only if you publish twice , on the second attempt of publishing the node, does it return a node. Has anyone else got this issue. on the latest umbraco 7.1.6
Yes, the cache is not updated until after the publish event, so you cannot get the new Published Content form TypedContent immediately.
There is a legacy event you can use which occurs after the cache has been updated. Details in this post and also there is a new event CacheUpdated which you can find out about here
Hi
public class CountryAfterCacheUpdated : ApplicationEventHandler { public CountryAfterCacheUpdated() { CacheRefresherBase
The event for removing and adding worked perfectly
Thanks
is working on a reply...