This project is read-only.

Projection Query Sort a group of elements firsts

Topics: Customizing Orchard
Mar 5, 2013 at 1:39 PM

I have some tags associated with a user and I want to show all posts associated with these tags and then the ones that are not associated.

I tried creating a SortCriterion but the only sorting I can do is with Asc, Desc or Random. I can not declare them to be sorted out with a list of tag ids.

Please, any idea of how to show some elements firsts and then the others?
Thanks in advance!!!
Mar 6, 2013 at 4:06 PM
I have been doing some testing and the way I am able to do it is with an action from the controller.

Simply fetch the post that are associated and add the ones that are not associated. Then I create a shape of Parts_Blogs_BlogPost_List and display it.

This solution is less flexible because I cannot use the filters dynamically.
Any better idea? :-)
Mar 6, 2013 at 10:35 PM
You could try implementing your own ISortCriterionProvider.
Mar 7, 2013 at 8:19 AM
Thanks for your reply but I am not sure how to do it :-(. I am kind of new in this Orchard environment...

It is like I create my interface INewSortCriterionProvider and then create my own method to create my special order by?

Also, I have noticed that there are only this methods for sorting by in the class IHqlQuery.cs:
public interface IHqlSortFactory {
    /// <summary>
    /// Sorts by ascending order
    /// </summary>
    void Asc(string propertyName);

    /// <summary>
    /// Sorts by descending order
    /// </summary>
    void Desc(string propertyName);

    /// <summary>
    /// Sorts randomly
    /// </summary>
    void Random();
Please could you give me some hints of where i can start? :-)
Mar 7, 2013 at 10:58 PM
Edited Mar 7, 2013 at 10:58 PM
You don't have to create your own interface; instead, you create a class that implements ISortCriterionProvider. Look at existing implementations to see how the're using the HQL API to implement sorting. Unfortunately there is no documentation on how to use this, so you will have to do some trial and error.