Timeline for Glass GetItems not returning sorted items
Current License: CC BY-SA 4.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 4, 2019 at 16:20 | vote | accept | ToddB | ||
Oct 4, 2019 at 16:19 | comment | added | ToddB |
We are using interfaces with Glass so the base child item does work but Glass does not let you do InferType with Interfaces so it still causes issues because we can't get to the real type. I solved this by adding __sortOrder to the base interface object so now when a collection is returned we can sort it by the value of that field.
|
|
Oct 4, 2019 at 13:34 | comment | added | Anicho |
@ToddB create a base class & template that all the parent items that can have the same children inherit. Then in glass get the parent items based on the base class which uses SitecoreChildren to get all the different types of children. That is how I've tackled it in the past.
|
|
Oct 2, 2019 at 18:28 | comment | added | ToddB |
Looking into that. The challenge is I have multiple types that could have these as children so I have to setup the Child map on all those. It also makes the rendering less reusable as content authors can't just add this child items and put renderings on the screen. The other option is try and try get __sortOrder mapped to the Glass item but can't seem to get that field to map.
|
|
Oct 2, 2019 at 18:17 | comment | added | Marek Musielak♦ |
Why don't you get the parent item itself using Glass and use Glass SitecoreChildren on that parent item Children property?
|
|
Oct 2, 2019 at 15:10 | comment | added | ToddB | To phrase that another way, this means there is no way to get a sorted list from Glass using any of the GetItems methods. Your statement makes sense but I am just confused by a previous post (really wish I could find it again) where Mike said it should. But since I can't find that post again it is probably a misunderstanding. Just thought Glass would have a way to get children of a certain type in order. Sounds like I just need to change how we are getting these items and use more of a child model. | |
Oct 2, 2019 at 14:55 | history | answered | Marek Musielak♦ | CC BY-SA 4.0 |