Copied to clipboard

Flag this post as spam?

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


  • Corné Hoskam 1 post 71 karma points
    Apr 14, 2020 @ 11:28
    Corné Hoskam
    0

    Publishing/Published Event in Split view Publish (8.6.0)

    Hi all,

    We have recently had some issues involving the Events fired from the Publishing/Published Events in combination with the split view editing mode within the default ContentService.

    When editing an Item in multiple languages through split view, and then publishing said Item in multiple languages, it only fires the proper events for a single language. To be even more precise, when publishing two languages, it only fires the event for the item in the Default Culture and not the second language that is being published. Is this a known issue or is there any way to circumvent this issue to force each and every item & culture being published to fire off the corresponding events?

    See the code snipped below for more details about our event handling Component.

    Thanks in advance!

    ~Corné

    In this example snippet the culture variable is always the Default culture, even when the Item is being published in multiple languages, and is also only called ones.

    private static void PublishingEventAction(IContentService sender, ContentPublishingEventArgs e)
    {        
            foreach (var content in e.PublishedEntities.Where(c => c.ContentType.Alias.InvariantEquals(NewsArticleItem.ModelTypeAlias)))
            {
                var culture = GetCurrentCulture(content, e);
            }
    }
    
    public void Initialize()
    {
            ContentService.Publishing += PublishingEventAction;
    }
    
    private static string GetCurrentCulture(IContent content, ContentPublishingEventArgs e)
    {
            foreach (var culture in content.CultureInfos)
            {
                if (e.IsPublishingCulture(content, culture.Culture))
                {
                    return culture.Culture;
                }
            }
    
            return string.Empty;
    }
    
  • 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