Sorting a Containable Item by a field?

Topics: Customizing Orchard, Writing modules
Feb 8, 2012 at 5:17 AM

lets say I have a custom object that has a container.  lets also assume that I have a custom content type that contains a field called order. Without resorting to code and rather using the cshtml for the custom container object, how would I sort of the items by the order field before displaying them?

I have read the documentation here and it covers some basic filtering on the object Custom Fields 1,2,3 etc.  Not on specific content fields... I see this in the cshtml for the list:

 

@{    IEnumerable<object> items = Model.ContentItems;   

Model.ContentItems.Classes.Add("content-items");   

Model.ContentItems.Classes.Add("list-items");}

@Display(items)

 

which obviously lists the items in it's list but there is nothing obviously showing where the filtering is happening unless it's happening in the router instead?  Without touching code, what's the best way to handle this?

Coordinator
Feb 8, 2012 at 6:23 AM

USe the new Projector feature in 1.4 for that when it's out, or sync to the latest in the 1.x branch.

Feb 9, 2012 at 4:02 AM
bertrandleroy wrote:

USe the new Projector feature in 1.4 for that when it's out, or sync to the latest in the 1.x branch.

If that isn't possible because we are fixed into the 1.3.10 currently, is there a short term workaround?

Coordinator
Feb 9, 2012 at 5:03 AM

Yes: don't use a field (which are not queryable in 1.3) but use a property on a part instead. Then you'll be able to do pretty much arbitrary queries through ContentManager.Query.