We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42042
    • 140 Posts
    Hi all,

    Quick question about getResources, I use modX 2.2.7 and the latest version of getResources.

    Question: What do I put at the &sort=`` option to sort them by how they are organized in the system?


    Thanks in advance smiley


    Cheers,
    Ilja

    This question has been answered by multiple community members. See the first response.

      • 10208 ☆ A M B ☆
      • 1,780 Posts
      Nothing. Leave that out. It will use the default sorting which is the resource tree hierarchy. (or any other parent you wish to show the children of, or alternately, if you're using it on the parent resource itself, set &parents=`[[*id]]` to use the current resource)

      It doesn't say it specifically in the documentation, that I noticed but default for sortBy is the resource tree structure.

        Frogabog- MODX Websites in Portland Oregon
        "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
        Having server issues? These guys have MODX Hosting perfected - SkyToaster
        • 42042
        • 140 Posts
        Quote from: frogabog at Jun 30, 2013, 10:57 PM
        Nothing. Leave that out. It will use the default sorting which is the resource tree hierarchy. (or any other parent you wish to show the children of, or alternately, if you're using it on the parent resource itself, set &parents=`[[*id]]` to use the current resource)

        It doesn't say it specifically in the documentation, that I noticed but default for sortBy is the resource tree structure.


        Hi Frogabog,

        Thanks voor the reply. I did let it out but nothing changes. I've added a screenshot, any ideas?



        Ilja
        • discuss.answer
          • 42602
          • 81 Posts
          You can set &sort=`menuindex` to it then you can use &sortdir=`ASC` or &sortdir=`DESC` depending which way you want them to be sorted. Cant remember which is default but would guess DESC
            • 42042
            • 140 Posts
            Quote from: dunnock at Jul 01, 2013, 06:54 AM
            You can set &sort=`menuindex` to it then you can use &sortdir=`ASC` or &sortdir=`DESC` depending which way you want them to be sorted. Cant remember which is default but would guess DESC

            Hi Dunnock,

            That's just sort them on their [[*id]] from high to low. I'd like to drag and drop them in order and that order must be the output sad

            Thanks for your time smiley

              • 42042
              • 140 Posts
              This is strange, The menuindex is correct in the tree but the output is not the same as i use &sort=`menuindex`.
              • discuss.answer
                • 4172
                • 5,888 Posts
                how about
                &sortby=`menuindex`
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 42042
                  • 140 Posts
                  Problem fixed, after I added sortdir it worked. Final call:

                  [[getResources?
                  &parents=`[[*id]]`
                  &tpl=`tmpl`
                  &includeTVs=`1`
                  &processTVs=`1`
                  &includeContent=`1`
                  &limit=`50`
                  &showHidden=`1`
                  &sortby=`menuindex`
                  &sortdir=`ASC`
                  ]]