I need the sort order of my item in a specific model.
I have tried it like this but no luck:
[SitecoreField("__Sortorder")]
public string SortOrder { get; set; }
Any idea how I can include standard fields in my model?
If this is not possible, actually I am working with a Checklist in that case, The AutoMapping from GlassMapper does return it in alphabetical order.
Here is the Definition of the Checklist Field:
IEnumerable<Guid> Filter_Tags_To_Shows {get; set;}
And like mentioned before, the list is returned in alphabetical order but I have no change to sort afterwards since missing the sortOrder field.
Thanks in Advance.
Your
Filter_Tags_To_Shows
property is returning a list ofGuid
s which, I presume, you are then doing something to get the linked Item from Sitecore. This is not the most efficient way and Glass allows you to specify the linked Item type which it will them automap.Assuming that the
FilterTagClass
has the sort order specified like in your question:You can sort using Linq:
This is a re-hash of the answer from @DougCouto but note it is not necessary to convert IDs to object if you set up the properties and mapping correctly.
As an alternative to using the
Checklist
field you can use theMultilist
field, which will allow you select tags and re-order them as required. Glass should return them in the same order you have set then.