Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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;
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();
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;
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted