Copied to clipboard

Flag this post as spam?

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


  • MarcC 49 posts 356 karma points
    Aug 15, 2016 @ 15:36
    MarcC
    0

    ListView Publish Events? Content Service?

    Hey,

    I need to add an event to happen as an item is getting published, usually I would use the ContentService and queue it up but when publising multiple documents within a ListView, it seems to skip this service?

    *EDIT: I assume it skips it as it doesnt display the message event I have created, where if a single node is published the message is displayed.

    Is there a different service the list view uses when doing batch publishing?

    enter image description here

  • Sven Geusens 169 posts 881 karma points c-trib
    Aug 16, 2016 @ 13:32
    Sven Geusens
    0

    I would find it very inconvenient if the list view used other services.

    I presume you are hooking into the ContentService.Published or .Publishing evemt?

    Could you show the code of how you are interacting with these events?

  • MarcC 49 posts 356 karma points
    Aug 17, 2016 @ 06:43
    MarcC
    0

    Just doesnt seem to behave the same way as single published nodes, here is a stripped back version where I would atleast hope for a message to pop up per item. In another test I tried adding an 'x' to the name of the document. Sadly, no effect on batch list view publishes.

    public class IndexDocumentsNews : ApplicationEventHandler
    {
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            ContentService.Published += ContentService_Published;
    
        }
    
        void ContentService_Published(IPublishingStrategy sender, PublishEventArgs<IContent> e)
        {
    
            foreach (var publishedEntity in e.PublishedEntities)
            {
                e.Messages.Add(new EventMessage("Indexed", publishedEntity.Name + " Has Been Indexed",
                           EventMessageType.Success));
    
            }
        }
    
    }
    
  • Sven Geusens 169 posts 881 karma points c-trib
    Aug 18, 2016 @ 08:48
    Sven Geusens
    0

    The code seems right, maybe the list view doesn't render the messages.

    Have you tried sending a message to the log to verify the event is fired or not?

    LogHelper.Info<ApplicationEventHandler>("{0} has been indexed.",publishedEntity.Name);
    

    Either way this warrants a bug report i think.

  • 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