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
Please bear with me if this has already been answered elsewhere. I have seen some other folks posting similar problems, but still no solution.
I'm iterating over a number of media items, and I want to sort them but it seems not to work whatever I do.
Here is an example, which doesn't sort the items:
var contacts = Umbraco.TypedMedia(1234).Descendants("Contact").OrderBy("SortOrder").ToList();
The SortOrder properties of all the items are all 0 (zero), like if I do this:
@contacts.Last().SortOrder
Sorting on this very same data actually works with XSLT. I can also see the SortOrder values in the Umbraco sorting UI.
I hope someone can point me in the right direction here.
Thanks!
Hi Joel,
From your code I can see that you are using strongly typed Razor. What if you are doing something like this, would it then work.
Try change
To
var contacts = Umbraco.TypedMedia(1234).Descendants("Contact").OrderBy(x => x.SortOrder).ToList();
Hope this helps,
/Dennis
Hi Dennis
Thanks for your reply.
Actually I wrote it just like you suggested in the first place, and then tried the strongly typed afterwards.
None of it works, I just tried it again now to make sure.
Any other good ideas? :)
/ Joel
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Missing SortOrder on Media Items - It always returns 0 (Umbraco 7)
Please bear with me if this has already been answered elsewhere. I have seen some other folks posting similar problems, but still no solution.
I'm iterating over a number of media items, and I want to sort them but it seems not to work whatever I do.
Here is an example, which doesn't sort the items:
var contacts = Umbraco.TypedMedia(1234).Descendants("Contact").OrderBy("SortOrder").ToList();
The SortOrder properties of all the items are all 0 (zero), like if I do this:
@contacts.Last().SortOrder
Sorting on this very same data actually works with XSLT. I can also see the SortOrder values in the Umbraco sorting UI.
I hope someone can point me in the right direction here.
Thanks!
Hi Joel,
From your code I can see that you are using strongly typed Razor. What if you are doing something like this, would it then work.
Try change
To
Hope this helps,
/Dennis
Hi Dennis
Thanks for your reply.
Actually I wrote it just like you suggested in the first place, and then tried the strongly typed afterwards.
None of it works, I just tried it again now to make sure.
Any other good ideas? :)
/ Joel
is working on a reply...