Copied to clipboard

Flag this post as spam?

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


  • Vishal G.P 62 posts 122 karma points
    Mar 19, 2018 @ 09:14
    Vishal G.P
    0

    Custom publish event works for single page publish but not for bulk publishing

    So below code works fine when just publishing a single page. But when right-click and publish all subpages (checkbox) it doesnt work for all the childs (which are of the type Person).

    I read that in 2014 this was an issue , but i cannot believe that in umbraco 7.5.11 this still doesnt work properly...

    Any suggestions?

    public class SetUmbracoNaviHideEventHandler : IApplicationEventHandler
    {
        public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
    
        }
    
        public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
    
            ContentService.Publishing += ContentService_Publishing;            
        }
    
        private void ContentService_Publishing(IPublishingStrategy sender, PublishEventArgs<Umbraco.Core.Models.IContent> e)
        {
            //only for Persons set the umbraconavihide property to true by default, if not already.
            foreach (var node in e.PublishedEntities)
            {                
                if (node.ContentType.Alias.InvariantEquals(DocumentTypeAliases.Person) && !node.GetValue<bool>("umbracoNaviHide"))
                {
                    node.SetValue("umbracoNaviHide", true);                    
                }
            }
        }
    
    
    
        public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
    
        }
    }
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies