Copied to clipboard

Flag this post as spam?

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


  • Jacques Nel 2 posts 52 karma points
    Sep 05, 2014 @ 12:13
    Jacques Nel
    0

    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

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Sep 05, 2014 @ 14:18
    Jeavon Leopold
    0

    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

  • Jacques Nel 2 posts 52 karma points
    Sep 08, 2014 @ 10:40
    Jacques Nel
    100

    Hi

    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

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft