Copied to clipboard

Flag this post as spam?

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


  • John Churchley 272 posts 1258 karma points c-trib
    Aug 24, 2015 @ 10:54
    John Churchley
    0

    Change SortOrder on Saving Event

    Hi,

    I'm trying to reorder siblings when a content node is saved based on a a date property type. Anyone got any ideas?

          public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
                    {
                        ContentService.Saved += ISaving;
                    }
    
    
         private void ISaving(IContentService sender, Umbraco.Core.Events.SaveEventArgs<Umbraco.Core.Models.IContent> e)
                {
                    var IPages = e.SavedEntities.Where(x => x.ContentType.Alias == "IPage");
                    if (IPages .Count() > 0)
                    {
                        foreach (var page in IPages )
                        {
                            try
                            {
                                if (!page.HasProperty("publishedDate") || page.GetValue<DateTime>("publishedDate") != null)
                                {
                                    page.SetValue("publishedDate", page.CreateDate);
                                }
                                 sender.GetParent(page.Id).SortOrder = ?????
                            }
                            catch (Exception ex)
                            {
                                LogHelper.Info(this.GetType(), ex.Message.ToString());
                            }
                        }
    
    
                    }
                }
    
Please Sign in or register to post replies

Write your reply to:

Draft