I have posted this over on the Taxonomies module discussion (http://orchardtaxonomies.codeplex.com/discussions/282668), but it is probably generic enough to warrant a post here too.
Disclaimer... this is probably something that I should be using Projector for, but I am now close to going live and don't really have the time before that to jump, plus its still in beta!
I really need to sort the list of content items rendered when viewing a taxonomy term. As this is going to be throw away code that I just need to get working asap, I am hacking the taxonomy module, feel dirty about that!!
The ordering is currently handled in the TaxonomyService code, GetContentItems. Here I check that I'm dealing with the appropriate term and then I want to implement my custom ordering. To do this I have had to add a reference to my
module. This works fine for simple sorting, however my requirement is slightly more completed.
The terms are attached to my custom Course type. This type also contains a relationship to many course deliveries (times at which the course is delivered). Now I need to order the Courses based on the start date of the most recent delivery, that
is ending in the future. Any courses that have no deliveries, or the delivery dates have passed need to be positioned at the end of the list. Quite a complex one!!!
From what I have read the IContentQuery does not support complex ordering. So I have been focusing my attention on using the _termContentItemRepository, but I can't even seem to get a simple linq select to work that returns the TermPart!
(from terms in _termContentItemRepository.Table
where terms.TermRecord.Id == term.Id ||
terms.TermRecord.Path.StartsWith(term.FullPath + "/")
I think the problem here is to do with the GetTerm, but how do I return a TermPart from this query?
Am I going down the correct path for this? How would others do it? Should I be creating my own route that overrides the taxonomy one and do this in my own controller?
Thanks for any help