Copied to clipboard

Flag this post as spam?

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


  • Magnus Söderlund 19 posts 79 karma points
    Jan 07, 2014 @ 11:14
    Magnus Söderlund
    0

    Cannot get content tree to update after custom sorting

    Hello.

    I'm trying to add a custom sorting routine for certain nodes when they are added or saved in my content tree. I am using the new API's with ContentService etc. 

    Here is my sorting method:

     int id = headNodeIdToSort();
            List<IContent> children = new List<IContent>();
            children.AddRange(ApplicationContext.Current.Services.ContentService.GetChildren(id));
    
            children.Sort(new AlphabeticCompare());
    
            for (int i = 0; i < children.Count; i++)
            {
              children[i].SortOrder = i;
            }
    
            umbraco.library.RefreshContent();

    Everything works like a charm except that my content tree is not automatically updated, even though i am calling "RefreshContent()". I have to manually perform a "Reload nodes" in the backoffice to see the results of my sort.

    Any ideas on how to get this to work without manual interaction?

  • Jeroen Breuer 4909 posts 12266 karma points MVP 5x admin c-trib
    Jan 07, 2014 @ 12:03
    Jeroen Breuer
    100

    Hello,

    There probably is a new way of doing this, but with the old API this worked: http://our.umbraco.org/projects/website-utilities/gecko-uploadify/feedback,-suggestions,-bugs/13119-Reload-tree-after-uploading

    Jeroen

  • Magnus Söderlund 19 posts 79 karma points
    Jan 08, 2014 @ 08:29
    Magnus Söderlund
    0

    Thank you Jeroen, the link you posted works for me. I also found a newer way of presenting speechbubbles but that did not give me the content tree refresh i am looking for. So untill i find something better to use i'll stick with this solution.

    Edit:

    I made a small error in my attempt to use the newer version to present a speechbubble. I tried again and got it to work by using the following code:

    using Umbraco.Web.UI.Pages;
    using Umbraco.Web.UI;
    ClientTools ct = new ClientTools((Page)HttpContext.Current.CurrentHandler);
    ct.SyncTree(ApplicationContext.Current.Services.ContentService.GetById(content.ParentId).Path, true).ShowSpeechBubble(Umbraco.Web.UI.SpeechBubbleIcon.Save, "Nytt innehåll", String.Format("{0} har lagts till som {1}", content.Name, content.ContentType.Alias));

    So now i can get my content tree updated without using old obsolete methods. 

  • 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