I set up my solution with the umbraco starer kit. It has a slider editor that is controling the blogs on a page. After I had lot of blogs imported, the sliderworks OK except that I can’t control the order of the displayed blogs. The pages are showing oldest to newest, but I need the blogs to be reversed. So I added a new blog and it goes to the bottom under the blogs document type in back office. This blog has a newer date that the ones I imported. Interestingly enough this newly created blog is still on the last page. I tried moving blogs around with sort children and then I added the publish date to the blogs collection and sorted by publish date. That didn’t fix anything. See screenshots. I certianly can re-import everything descending, but my concern is as soon as someone adds a new blog it will still show up on the last page. Any help would be greatly appreciated.
You don’t say what version you’re using - looks like v16.
Just looked in a v13 start kit - you need to amend the macro partial that renders these to change to the sort order. I think it’s the same in v16 - will have a look for a quick setup to check.
Look in Views\MacroPartials\LatestBlogPosts.cshtml
Line 37
var blogposts = startNode.Children.OrderBy(x => x.CreateDate).ToList();
Change to
var blogposts = startNode.Children.OrderByDescending(x => x.SortOrder).ToList();
Thanks Steve, I have v16. But it doesn’t matter that much. What you’re saying works for sorting each page. However, the order of all pages are still reversed. At that point you’re talking about it’s passing in the number of blogs selected with the slider. What I can’t seem to find is where the code is pulling all the blogs. If I could then I would change the sort order at that point in the code.
On views/partials/b;ockgrid/components/latestblogposts.cshtml:
Confession time - I’ve never used the sample site But it looks like from V16 the code you’re looking for isn’t actually installed by the package - it’s just present in a dll - this is not much help for you!
The ViewComponent code can be seen here though:
As you’re looking to amend and customise what I’d suggest you do is copy this but rename it. Create your own View Component based on this so you can amend and make perfect as you wish.
Sounds good Steve! I really appreaciate your help! I’ll give it a shot, but it looks like it could work. I’ll let you know if I have further questions.