We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29019 ☆ A M B ☆
    • 104 Posts
    This might be a long shot, but if it’s throwing the sortby field right into the sql... this *might* work with mysql:

    &sortby=`FIND_IN_SET(id, ’comma,separated,id,list’)
    &sortdir=`desc`

    This would work assuming getResources uses IN (comma,separated,id,list) for the query (I suspect it does).

    Good luck!
      www.darkstardesign.com

      Are you in the Nashville area? Join us for our next MODX meetup!
      • 22303 MODX Staff
      • 10,725 Posts
      Quote from: swespi at Mar 29, 2011, 08:38 AM

      This might be a long shot, but if it’s throwing the sortby field right into the sql... this *might* work with mysql:

      &sortby=`FIND_IN_SET(id, ’comma,separated,id,list’)
      &sortdir=`desc`

      This would work assuming getResources uses IN (comma,separated,id,list) for the query (I suspect it does).
      Let me know if that works—it should as long as you do not set sortbyEscaped to 1 (Yes in property set), assuming that function does what you need.
        • 7557
        • 61 Posts
        Quote from: mindeffects at Mar 29, 2011, 07:22 AM

        Quote from: TomMLS at Mar 29, 2011, 07:09 AM

        Why does modifying the menu ids not provide you the "EXACT" order you want??
        The menu id is a separate data field from the resource id, which is immutable, the MODx developers do not recommend changing it.
        End users never see either ID number, they only see the output.

        Sorry, Tom, it’s not exact because the resources are located in different parts of the tree and are on no order at all. It’s just like "4,7,2,5,1".

        And it’s a "backend" thing! I put those "related articles" in a TV as an comma separated list, like "4,7,2,5,1".
        Try this:
        &sortby = 'FIELD(modResource.id, 4,7,2,5,1 )';
          • 30319
          • 406 Posts
          Quote from: dj13 at Mar 29, 2011, 01:59 PM

          Try this:
          &sortby= = 'FIELD(modResource.id, 4,7,2,5,1 )';


          Ohhhhhh...that looks awesome. smiley
          Better yet, should not require any code changes.
          Plus all one must do is publish or unpublish a document to have it appear or not appear.
          Very nice elegant solution. smiley

          Thank you, Tom
            • 19604 ☆ A M B ☆
            • 179 Posts
            Quote from: TomMLS at Mar 29, 2011, 02:02 PM

            Quote from: dj13 at Mar 29, 2011, 01:59 PM

            Try this:
            &sortby= = 'FIELD(modResource.id, 4,7,2,5,1 )';

            Ohhhhhh...that looks awesome. smiley Better yet, should not require any code changes.
            Plus all one must do is publish or unpublish a document to have it appear or not appear.

            Yes, that worked PERFECTLY! Thanks dj13! But where does your mighty vodoo come from? "FIELD"? Never heard of. "modResource.id" same for this. Something in the docu that I missed? Do you have a reading hint for me? ;-)

            BTW: I created a chunk containing "FIELD(modResource.id,[[*related]])", with the TV "related" containing the comma seperated list of IDs. And with this the getResources-call says "... sortby=’[[ $relatedHelper]]’ ...". Works fine. Then I got an idea:

            @openGeek: Wouldn’t it be nice to have this implemented directly into getResources, e.g. "... sortby=’resources’ ..."? Shouldn’t be to tough to code. ;-)
              MINDEFFECTS – DESIGN for PRINT, WEB and MEDIA
              http://twitter.com/mindeffects · http://www.facebook.com/mindeffects · http://www.youtube.com/mindeffects/ · skype://mindeffects_oliver
              • 22303 MODX Staff
              • 10,725 Posts
              Quote from: mindeffects at Mar 29, 2011, 03:20 PM

              @openGeek: Wouldn’t it be nice to have this implemented directly into getResources, e.g. "... sortby=’resources’ ..."? Shouldn’t be to tough to code. ;-)
              It will be indeed be implemented wink
                • 19604 ☆ A M B ☆
                • 179 Posts
                Quote from: OpenGeek at Mar 29, 2011, 03:27 PM

                Quote from: mindeffects at Mar 29, 2011, 03:20 PM

                @openGeek: Wouldn’t it be nice to have this implemented directly into getResources, e.g. "... sortby=’resources’ ..."? Shouldn’t be to tough to code. ;-)
                It will be indeed be implemented wink

                Hoorayyy!!!
                  MINDEFFECTS – DESIGN for PRINT, WEB and MEDIA
                  http://twitter.com/mindeffects · http://www.facebook.com/mindeffects · http://www.youtube.com/mindeffects/ · skype://mindeffects_oliver
                  • 4172
                  • 5,888 Posts
                  wow, this is great.
                  I didn’t know about this FIELD function for sorting.
                  http://dev.mysql.com/doc/refman/5.0/en/sorting-rows.html
                  search for: Posted by Eamon Daly on March 28 2005 6:16pm
                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                    • 19604 ☆ A M B ☆
                    • 179 Posts
                    @MODX: "Have I told you lately that I love you?"

                    Boy, am I glad I switched to MODX!!!
                      MINDEFFECTS – DESIGN for PRINT, WEB and MEDIA
                      http://twitter.com/mindeffects · http://www.facebook.com/mindeffects · http://www.youtube.com/mindeffects/ · skype://mindeffects_oliver
                      • 36541
                      • 222 Posts
                      Quote from: mindeffects at Mar 29, 2011, 03:14 AM

                      Using "... &sortby=’resourses’ ..." is NOT working at all. Also GitHub isn’t much of a help: https://github.com/opengeek/getResources/pull/23

                      That pull request could not be merged. But there is a working one awaiting integration. I’ve been using it successfully for few moths now.

                      Quote from: OpenGeek at Mar 29, 2011, 03:27 PM

                      Quote from: mindeffects at Mar 29, 2011, 03:20 PM

                      @openGeek: Wouldn’t it be nice to have this implemented directly into getResources, e.g. "... sortby=’resources’ ..."? Shouldn’t be to tough to code. ;-)
                      It will be indeed be implemented wink

                      It’s waiting to be merged already. So, don’t hesitate wink
                        This is the web: the only thing you know about who will come is that you don't know who will come.