More in this section

Forums / Developing with Sitefinity / sortExp parameter when calling ContentManager.GetContent(..)

sortExp parameter when calling ContentManager.GetContent(..)

4 posts, 0 answered
  1. Nick
    Nick avatar
    91 posts
    Registered:
    04 Aug 2008
    28 Oct 2008
    Link to this post
    Hi all!

    I have recently been giving a functional requirment to be implemented in one of my controls. It involved adding a new meta field to news items and then ordering by this new meta field.

    However i also wanted to sub-order by Publication_Date. So when calling GetContent() i passed in the following string as the sortExp parameter: "NewMetaField desc, Publication_Date desc" (assuming that it would translate straight into SQL) but this throws an exception stating that "Publication_Date is not a valid column name" (or something to that effect)

    is there any way in which this can be achieved without having to sort programmatically by iterating through lists?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    30 Oct 2008
    Link to this post
    Hi Nick,

    Thank you for using our services.

    Currently, we do not support sorting by two or more meta keys. Probably, such implementations will be available in version 4.0 with the new Generic Content API.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    30 Oct 2008
    Link to this post
    Hi Nick,

    You could load the news items into an arraylist, and sort that instead.  

    http://msdn.microsoft.com/en-us/library/system.collections.arraylist.sort(VS.71).aspx

    Kind of a pain, but I've done this before with other stuff that's difficult to sort, and it's not too bad.  You can specify all sorts of sorting rules in your method.

    Regards,
    Mike
  4. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    31 Oct 2008
    Link to this post
    Hello Mike,

    Sure, this is a way, in case Nick decide to use some programming here.

    Best wishes,
    Georgi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Register for webinar
4 posts, 0 answered