Copied to clipboard

Flag this post as spam?

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

  • Dan 61 posts 185 karma points
    Jun 02, 2014 @ 11:06

    Sort notes in backend in alphabetical

    I need to sort my backend items in alphabetical where published item is at the bottom and the unpublished at top, but Im doing something wrong I don't know the type I have to use, I tried IContent and Document, they get sorted but it seams like they get duplicated also ?, I guess that's because Im making a new item in the database by saving the node again after changing the sortnr.

    int sortNr = 0;
    // unpublished 
    var contentService = ApplicationContext.Current.Services.ContentService;
    List<Umbraco.Core.Models.IContent> unpublished = contentService.GetChildren(parentNodeToSortedItems.Id).Where(x => !x.Published).OrderBy(x => x.Name).ToList();
    // published
    List<Document> publishedItems = new List<Document>();
    List<umbraco.interfaces.INode> published = parentNodeToSortedItems.ChildrenAsList.OrderBy(x => x.Name).ToList();
            foreach (var item in published )
                Document document = new Document(item.Id);
            for (int i = 0; i < unpublished.Count; i++)
                unpublished[i].SortOrder = i;
            for (int i = 0; i < p.Count; i++)
                p[i].sortOrder = sortNr;
                p[i].SaveAndPublish(new umbraco.BusinessLogic.User(0));
Please Sign in or register to post replies

Write your reply to: