We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34193
    • 330 Posts
    Quote from: OpenGeek at Oct 12, 2009, 09:16 PM

    Quote from: peteedley at Oct 12, 2009, 03:55 PM

    Quote from: OpenGeek at Oct 12, 2009, 03:40 PM

    &sortby=`RAND()` ?

    Fantastic thanks that doesn’t works but it did make me think about changing this line $criteria->sortby($sortby, $sortdir); to $criteria->sortby(’RAND()’);
    FYI, it doesn’t work because I’m a dumbass and used !empty() instead of isset() in all the default parameter tests. If you could pass &sortbyAlias=`` (and possibly &sortdir=``) it would work fine without any other changes:
    $sortby = !empty($sortby) ? $sortby : 'publishedon';
    $sortbyAlias = isset($sortbyAlias) ? $sortbyAlias : 'modResource';
    if (!empty($sortbyAlias) $sortby = "`{$sortbyAlias}`.`{$sortby}`";
    $sortdir = isset($sortdir) ? $sortdir : 'DESC';
    


    LOL ok will try it ltr that way, glad I’m not the only one who has dumbass moments
      • 9849
      • 74 Posts
      Is there a way to sort by multiple fields?

      e.g:
      &sortby=`menuindex,publishedon`


      Just seems to sorty by last value (publishedon).
        • 22303 MODX Staff
        • 10,725 Posts
        Not at the moment really; definitely something I want to add though.
          • 9849
          • 74 Posts
          Hey Jason,

          is there anything on schedule regarding getResources (sorting by multiple fields)?
          Just asking because I do not want to hack the snippet if you expect an update within the next days/week(s).

          Thank you
            • 22303 MODX Staff
            • 10,725 Posts
            Quote from: florian.l at Jun 11, 2010, 04:03 AM

            is there anything on schedule regarding getResources (sorting by multiple fields)?
            Just asking because I do not want to hack the snippet if you expect an update within the next days/week(s).
            I should have some time tonight or tomorrow to work on this. Will keep you posted.
              • 9849
              • 74 Posts
              That really would be awesome! Thank you in advance.
                • 9849
                • 74 Posts
                Have you already had the time to look at multiple sort? Sorry for being so pesky.
                  • 22303 MODX Staff
                  • 10,725 Posts
                  Quote from: florian.l at Jun 23, 2010, 07:20 AM

                  Have you already had the time to look at multiple sort? Sorry for being so pesky.
                  No, my apologies, have had a lot on my plate recently. Will look at it tonight for sure.
                    • 9849
                    • 74 Posts
                    Hm, still no multiple sort? And I just realized that one cannot sort by a TV either, is that correct?
                      • 22303 MODX Staff
                      • 10,725 Posts
                      Quote from: florian.l at Jul 14, 2010, 05:41 AM

                      Hm, still no multiple sort? And I just realized that one cannot sort by a TV either, is that correct?
                      Yeah, it is not as easy as I thought to implement either of these types of things without completely destroying the performance of the existing features. I’ll work on it more as I have time, but a generic solution to this is not going to happen overnight. In the meantime, I suggest writing a simple Snippet that looks specifically at the data you want it to. This will be much more efficient anyway, and you can use getResources as the model; just modify the query and you can still use the getPage Snippet with it, etc.